Page 1 of 1

Insert text/html snippets into several products.

Posted: Mon Feb 19, 2018 4:58 pm
by tstirler
I'm looking for a way to insert a snippet of text or html/php into several products via text I choose in the product-text.

Example: I have several products that have the same options and I want the product-text to show some info about it, but I don't want to edit all the products if I need to change the text a bit.
How can I enter a tag into the product-text, and have opencart swap out the tag with the text I want?
If I just do a php include in the product-text opencart comments out the php code.

running Opencart 3.0.2.0, and I have vqmod installed. There is no mod in question, rather where to parse the product-text for a specific tag.
Edit: cleared up question.

Re: Insert text/html snippets into several products.

Posted: Tue Feb 20, 2018 6:00 am
by straightlight
Code example / attachment un-provided nor knowing if this request is about a specific extension being used.

Re: Insert text/html snippets into several products.

Posted: Tue Feb 20, 2018 2:54 pm
by tstirler
I'll rephrase the question a bit then. :)
What file parses out the Product Info (vanilla OC 3)? I think it should be catalog/model/catalog/product.php.
So that I can scan it for a tag I choose to make and if I find it insert my text/html/php code there.
I see that the query around line 10 fetches and returns the array of data.

Code: Select all

if ($query->num_rows) 
But I've not found a place where I can actually do something with that piece of text.

What I want to insert is a standard set of info, say from my own php-file somewhere, pulled in via a standard php-include. That way I have one place to change the included text and it'll change for all products that use it.
I have no proper code example yet since I've not managed to find where I want said code.
Although it will be a simple: if tag found replace with php-include

Re: Insert text/html snippets into several products.

Posted: Tue Feb 20, 2018 6:15 pm
by straightlight
Better to use OCMod, VQMod or the override engine to do this without overriding core files. You could also create an extension module and route it to the product page to make things easier by also adding a new model file (might use a bit more SQL resource but still works).

Re: Insert text/html snippets into several products.

Posted: Tue Feb 20, 2018 6:59 pm
by tstirler
I thought as much. I've no problem doing this with vqmod, if I could just get it to work. :laugh:
Do I need to hook into product.php to catch this?
I tried earlier to do it via the template (now twig) but it didn't change it for me.