Post by imager » Fri Sep 18, 2020 7:43 am

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??

New member

Posts

Joined
Fri Nov 09, 2012 7:05 pm

Post by letxobnav » Fri Sep 18, 2020 8:39 am

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

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;
				} 
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...

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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 26 guests