skpacman replied to the thread
function add_to_head how work?
As far as I can tell, with my limited knowledge:
in output_handling_include.php, the code is first passed to:Codefunction add_to_head($tag=""{
global $fusion_page_head_tags;
if(!stristr($fusion_page_head_tags, $tag)){
$fusion_page_head_tags .= $tag."\n";
}
}
Where it's forced into the $output by:Codefunction 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("##", $fusion_page_footer_tags."", $output, 1);
}
if(!empty($fusion_page_head_tags)){
$output = preg_replace("##", $fusion_page_head_tags."", $output, 1);
}
if($fusion_page_title != $settings['sitename']){
$output = preg_replace("#.*#i", "".$fusion_page_title."", $output, 1);
}
if(!empty($fusion_page_meta)){
foreach($fusion_page_meta as $name => $content){
$output = preg_replace("##i", "", $output, 1);
}
}
if(!empty($fusion_page_replacements)){
eval($fusion_page_replacements);
}
if(!empty($fusion_output_handlers)){
eval($fusion_output_handlers);
}
return $output;
} Notice the "$fusion_page_head_tags" being returned to $output in there?
Then, in the header.php, it sets up the rest of the header and starts the content of the page with ob_start(), basically making the output of the page an object.
In footer.php, it closes the object, takes its output, combines it with the rest of $output, then returns the whole thing to the browser.
The preg_replace stuff in handle_output() is where the magic happens.
I don't know how you would implement this in your own code outside of php-fusion, but at least it helps to (mostly) know how php-fusion does it.
23 Jan 2015 at 07:37 PM