Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

add_to_head

Asked Modified Viewed 1,696 times
M
MiChAeLoKGB
M
Sorry for my English.
Im from Slovakia wink
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

Hi,

first, Im sorry if its in wrong category, but IDK where else should I put it.

I have a non Php-Fusion web where I need to use this function, so I edited my web and added this function (everything I found I think is needed for it) & now it have code like this (its easier for me to show you code than explain everything, cos mine english is bad):

core:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$fusion_page_replacements = "";
$fusion_output_handlers = "";
$fusion_page_title = $settings['sitename'];
$fusion_page_meta = array("description" => $settings['description'], "keywords" => $settings['keywords']);
$fusion_page_head_tags = "";
$fusion_page_footer_tags = "";

function set_title($title=""wink{
global $fusion_page_title;

$fusion_page_title = $title;
}

function add_to_title($addition=""wink{
global $fusion_page_title;

$fusion_page_title .= $addition;
}

function set_meta($name, $content=""wink{
global $fusion_page_meta;
$fusion_page_meta[$name] = $content;
}

function add_to_meta($name, $addition=""wink{
global $fusion_page_meta;
if(isset($fusion_page_meta[$name])){
$fusion_page_meta[$name] .= $addition;
}
}

function add_to_head($tag=""wink{
global $fusion_page_head_tags;

if(!stristr($fusion_page_head_tags, $tag)){
$fusion_page_head_tags .= $tag."\n";
}
}

function add_to_footer($tag=""wink{
global $fusion_page_footer_tags;

if(!stristr($fusion_page_footer_tags, $tag)){
$fusion_page_footer_tags .= $tag."\n";
}
}

function replace_in_output($target, $replace, $modifiers=""wink{
global $fusion_page_replacements;

$fusion_page_replacements .= "\$output = preg_replace('^$target^$modifiers', '$replace', \$output);";
}

function add_handler($name){
global $fusion_output_handlers;
if(!empty($name)){
$fusion_output_handlers .= "\$output = $name(\$output);";
}
}

function handle_output($output){
global $fusion_page_head_tags ,$fusion_page_footer_tags, $fusion_page_title, $fusion_page_meta, $fusion_page_replacements, $fusion_output_handlers, $settings;

if(!empty($fusion_page_footer_tags)){
$output = preg_replace("#</body>#", $fusion_page_footer_tags."</body>", $output, 1);
}
if(!empty($fusion_page_head_tags)){
$output = preg_replace("#</head>#", $fusion_page_head_tags."</head>", $output, 1);
}
if($fusion_page_title != $settings['sitename']){
$output = preg_replace("#<title>.*</title>#i", "<title>".$fusion_page_title."</title>", $output, 1);
}
if(!empty($fusion_page_meta)){
foreach($fusion_page_meta as $name => $content){
$output = preg_replace("#<meta (http-equiv|name)='$name' content='.*' />#i", "<meta \\1='".$name."' content='".$content."' />", $output, 1);
}
}
if(!empty($fusion_page_replacements)){
eval($fusion_page_replacements);
}
if(!empty($fusion_output_handlers)){
eval($fusion_output_handlers);
}

return $output;
}[/syntaxhighlighter]

Header:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false] if (function_exists("get_head_tags"wink) { echo get_head_tags(); }
echo"</head><body>";
ob_start();[/syntaxhighlighter]


Footer (I had to coment out the first 2 lines, cos it totally deformed the main page with page_nav):

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]/*define("CONTENT", ob_get_contents());
ob_end_clean();*/

echo "
some content, blah blah...
</div>
</body>
</html>
";

$output = ob_get_contents();
if (ob_get_length() !== FALSE){
ob_end_clean();
}
echo handle_output($output);

if (ob_get_length() !== FALSE){
ob_end_flush();
}
mysql_close($db_connect);[/syntaxhighlighter]


When I add to page something like:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]add_to_head("<link rel='stylesheet' href='../core/styles.css' media='screen'>"wink;[/syntaxhighlighter]

It just doesnt work. Does somebody know what am I missing or some mistake I did?
I need only add_to_head & add_to_footer function, nothing else.
Edited by MiChAeLoKGB on 11-08-2013 15:35,
0 replies
There are no post found.

Category Forum

General Discussion

Labels

None yet

Statistics

  • Views 0 views
  • Posts 0 posts
  • Votes 0 votes
  • Topic users 1 member

1 participant

M
M
Sorry for my English.
Im from Slovakia wink
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet