I would like to include some common HTML (basically descriptive text) on a number of items in our shop. The goal is to have a common set of information that is maintained in one location and updated automatically on several pages that "include" that common text that is linked to.
I thought there was an Include HTML function, but I cannot seem to find one. Anyone give me some feedback on how to best update several products with link to include in the description pointing to a common HTML file?
Thoughts??
we use this in the product controller to include external html by placing a {{filename}} placeholder in the description, then the controller replaces that with the content of that file located in the includes directory
We mostly use this in the html module as that needs to be edited in the js editor which is always a pain and it stores the html in the settings table which is loaded every request so if the html is a little large...
Code: Select all
// get an include file instead of the entered html if indicated by {{filename}} pulled from the includes directory
$btoken = '{{';
$etoken = '}}';
$html = $data['description'];
$final_html = '';
$begin = '';
$end = '';
if (stristr($html,$btoken) and stristr($html,$etoken)) {
while (stristr($html,$btoken) and stristr($html,$etoken)) {
$bpos = strpos($html,$btoken);
$epos = strpos($html,$etoken);
$begin = mb_substr($html,0,$bpos);
$end = mb_substr($html,$epos+strlen($btoken));
$include_file = mb_substr($html,$bpos+strlen($btoken),$epos-$bpos-strlen($etoken));
ob_start();
include(DIR_INCLUDES . $include_file);
$include_html = ob_get_clean();
if ($include_html) $final_html .= $begin.$include_html;
$html = $end;
}
$data['description'] = $final_html . $end;
}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Who is online
Users browsing this forum: Bing [Bot], mattltm and 332 guests