Zen Cart Logo
Forums / General Questions / Insert an EZPage into Product Descriptions or other Pages

Insert an EZPage into Product Descriptions or other Pages

Views: 1,237

Results 1 to 11 of 11
22 Sep 2015, 3:48 PM
#1
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Insert an EZPage into Product Descriptions or other Pages

Greetings,

I'm working on a new site that uses common statements for some of the product descriptions (Ex. This product is Certified Organic). This statement is in addition to the specific description of each product.

I would like to create the ability to insert an EZpage (that has the common statement) into products descriptions. This way, if one needs to change the common statement, it is done on the EZpage, not ALL of the products descriptions!

Also, if I'm going to do this, I might as well have the ability to add an EZpage to any of the define pages or even other EZpages (except for the EZpage that is inserting it's self). I think this may make a good Plugin too!:D

Here's my thinking, I would use a template style placeholder that has the EZPage IDs as it's value.

Example:

  1. Here is a product description an I want to insert a few EZpages here {{12, 24, 2}} and maybe one here {{3}} as well!

Or if easier to code

  1. Here is a product description an I want to insert a few EZpages here {{12}}{{24}}{{2}} and maybe one here {{3}} as well!

I have the logic flow sort of figured, but not the PHP skills to code without help! My thinking is to break apart the description into an array at the placeholders and store the placeholders in a 2D array (to support multi ID's per placeholder). Then, loop through the placeholders 2D array, striping out the IDs and make the EZpage calls, concatenate the results into a new 1D array. This would now leave you with two 1D arrays that can now be re-assembled.

My initial hurtle is how one would go about breaking apart the description into the two arrays, product description parts and placeholders with the IDs of the EZpages? If one could think of a better approach, I'm open! :smile:

22 Sep 2015, 3:59 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Insert an EZPage into Product Descriptions or other Pages

I think if you check out swguy's website and look for boilerplate code or elsewhere in the forum, it does/offers the ability to do exactly what you are trying to accomplish... There certainly are other ways as well with adding other "programmable" options to put content on all pages that could then be CSS controlled (not exactly advised as the CSS would send the information to everyone to include a "hide" statement where not desired to be shown and increase bandwidth usage). Other methods could be used also to "track" which items should have which display information and PHP or PHP/MySQL could sort it out.

23 Sep 2015, 6:34 PM
#3
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Re: Insert an EZPage into Product Descriptions or other Pages

mc12345678:

I think if you check out swguy's website and look for boilerplate code or elsewhere in the forum, it does/offers the ability to do exactly what you are trying to accomplish... There certainly are other ways as well with adding other "programmable" options to put content on all pages that could then be CSS controlled (not exactly advised as the CSS would send the information to everyone to include a "hide" statement where not desired to be shown and increase bandwidth usage). Other methods could be used also to "track" which items should have which display information and PHP or PHP/MySQL could sort it out.

Thanks mc12345678,

Couldn't find any place on swguy's website that has boilerplate code...already searched through the ZC forums before I posted, but doesn't mean I didn't miss something! :blink: ...would be great if you could point me to a ZC forum page to get me going!

23 Sep 2015, 6:52 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Insert an EZPage into Product Descriptions or other Pages

kwright:

Thanks mc12345678,

Couldn't find any place on swguy's website that has boilerplate code...already searched through the ZC forums before I posted, but doesn't mean I didn't miss something! :blink: ...would be great if you could point me to a ZC forum page to get me going!

Sometimes the best information is found by searching from outside the forum on items in the forum...

https://www.zen-cart.com/showthread.php?117965-Boilerplate-mod-separate-it-from-description

Is at least a thread that leads to the code and discusses it a little... I believe there are others in the forum. :)

23 Sep 2015, 8:08 PM
#5
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Re: Insert an EZPage into Product Descriptions or other Pages

mc12345678:

Sometimes the best information is found by searching from outside the forum on items in the forum...

https://www.zen-cart.com/showthread.php?117965-Boilerplate-mod-separate-it-from-description

Is at least a thread that leads to the code and discusses it a little... I believe there are others in the forum. :)

Excellent! I'll read through the thread and look at the boilerplate code! I hope it will allow one to insert boilerplate text in the middle of the description and not just before or after...

I did go back to That Software Guy's site and found the boilerplate code you first had mentioned under Tips and Tricks. :blush:

Thanks again mc12345678 :D

23 Sep 2015, 8:12 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Insert an EZPage into Product Descriptions or other Pages

kwright:

Excellent! I'll read through the thread and look at the boilerplate code! I hope it will allow one to insert boilerplate text in the middle of the description and not just before or after...

I did go back to That Software Guy's site and found the boilerplate code you first had mentioned under Tips and Tricks. :blush:

Thanks again mc12345678 :D

From looking at the code and explanation of how to use (sometime in the last couple of years) yes it can be applied throughout... In fact that's why it was developed because the desre was to implement something within the description area. There are some strategies that need to be appled, but should serve the desired process..

25 Sep 2015, 1:23 AM
#7
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Re: Insert an EZPage into Product Descriptions or other Pages

mc12345678:

From looking at the code and explanation of how to use (sometime in the last couple of years) yes it can be applied throughout... In fact that's why it was developed because the desre was to implement something within the description area. There are some strategies that need to be appled, but should serve the desired process..

Just had a good look-through of the code and forum thread. The boilerplate mod seems to be close enough to get me going!

Thanks

25 Sep 2015, 1:41 AM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Insert an EZPage into Product Descriptions or other Pages

kwright:

Just had a good look-through of the code and forum thread. The boilerplate mod seems to be close enough to get me going!

Thanks

Was going to say, the first post of the above link referenced the basic instructions on how to use it. Essentially it is a search and replace of content in the description substituting whatever is referenced... The referenced information is up to your imagination, but it offers a way to consistently provide the content that can be "easily" changed as necessary and consistently... If that content is to end up being whatever is in an ez-page, then so be it. It's a way to make it happen. :)

25 Sep 2015, 3:56 PM
#9
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Re: Insert an EZPage into Product Descriptions or other Pages

mc12345678:

Was going to say, the first post of the above link referenced the basic instructions on how to use it. Essentially it is a search and replace of content in the description substituting whatever is referenced... The referenced information is up to your imagination, but it offers a way to consistently provide the content that can be "easily" changed as necessary and consistently... If that content is to end up being whatever is in an ez-page, then so be it. It's a way to make it happen. :)

Yes, now for what I would like to do is a bit more complicated since the code will not know what the reference (CONSTANT) will be until it is pulled out of the description and analyzed. The goal is to have a system where one can add any EZpage or pages to any description or other page from the Admin.

I believe I can use most of the boilerplate code. If I can use a variable rather than a constant as the reference in the description, then I could add a step that pulls the reference (ex. {{24}}), strip the {{}}, then make a call to EZpage table with ID=24, then replace the {{24}} in the description with the variable $ezp_24 and set the variable, $ezp_24='content of EZpage'. Then go about the code as intended.

Basically, replace the define with a variable on the fly in the description...

What do you think? :blink:

27 Sep 2015, 6:36 AM
#10
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Insert an EZPage into Product Descriptions or other Pages

kwright:

Yes, now for what I would like to do is a bit more complicated since the code will not know what the reference (CONSTANT) will be until it is pulled out of the description and analyzed. The goal is to have a system where one can add any EZpage or pages to any description or other page from the Admin.

I believe I can use most of the boilerplate code. If I can use a variable rather than a constant as the reference in the description, then I could add a step that pulls the reference (ex. {{24}}), strip the {{}}, then make a call to EZpage table with ID=24, then replace the {{24}} in the description with the variable $ezp_24 and set the variable, $ezp_24='content of EZpage'. Then go about the code as intended.

Basically, replace the define with a variable on the fly in the description...

What do you think? :blink:

So my thought is that there be some consistent information in the product description that is used to translate as necessary to give the final result... The code is such that whatever is provided can be "translated" to a desired final affect. If that is to take the number and apply it to a link for an EZ page, then that's what it will do. :)

3 Oct 2015, 12:35 AM
#11
kwright avatar

kwright

Zen Follower

Join Date:
Nov 2004
Posts:
355
Plugin Contributions:
0

Re: Insert an EZPage into Product Descriptions or other Pages

mc12345678:

So my thought is that there be some consistent information in the product description that is used to translate as necessary to give the final result... The code is such that whatever is provided can be "translated" to a desired final affect. If that is to take the number and apply it to a link for an EZ page, then that's what it will do. :)

Well, I had time to put my idea to code. Thanks again for your suggestions. It turned out not to be that difficult (I love regex!), and created a very nice solution.

I've created one new function to do all of the work. Just call the function, passing in the $products_description, and the function returns the $products_description with the desired EZ-Page(s) inserted where you need them. Only one small addition needs to be made to the tpl_product_info_display.php template file. Of course, you need to create the EZ-Page(s) too!

The above works since I have the product descriptions disabled in the Product Listing, New Listing, Featured Listing and All Listing pages. You would have to add the same snip-it of code to those files if you wanted this to work there too. :D