Forums / Features Wish List / Support for Boilerplate HTML Chunks

Support for Boilerplate HTML Chunks

Views: 195

Results 1 to 13 of 13
11 Oct 2018, 11:05 PM
#1
lloyd_borrett avatar

lloyd_borrett

Zen Follower

Join Date:
Mar 2006
Location:
Rosebud, Victoria, Australia
Posts:
308
Plugin Contributions:
2

Support for Boilerplate HTML Chunks

Is there an easy way to support the use of common boilerplate chunks of HTML in the descriptions of products?

We often need to put common chunks of HTML code into descriptions. For example, size charts, shipping restrictions, availability, special conditions, etc. But then when they change we have to locate them all and change each one individually.

It would be nice to define these common chunks of boilerplate HTML, give them a name, and then be able to insert them into descriptions easily. Then to change them, we just need to edit the chunk in one place.

The old Etomite CMS I've used made this possible on steroids. You could define a 'chunk' of named boilerplate HTML markup. Then in a description simply enclose the chunk name in double opening and closing brackets and the chunk of HTML would be inserted at run time. For example, say you created a chunk of HTML called 'cressi-mens-wetsuit-size-chart'. To insert it into a description you'd simply enter {{cressi-mens-wetsuit-size-chart}} and it would happen automatically at run time. Editing the contents of the chunk thus changed it everywhere at run time. The reason I say it worked on steroids is because you could have chunks in chunks, plus put JavaScript and PHP code into the chunks, to make them more powerful.

A simple version of this sort of thing, even if it only supported plain HTML, would be a great addition or add-on for Zen Cart.

Obviously there would need to be a way for the chunks to be expanded when retrieving the descriptions for things like Google Product Search Feeder creation and the like.

(The old Etomite CMS also supported having 'snippets' which were handled in a similar way. But snippets contained PHP code, which could call other snippets and chunks. The combination of snippets and chunks made that CMS very powerful.)

Zen Cart 1.5.5e, PHP 5.3.29 MySQL 5.5.42

12 Oct 2018, 2:02 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Oct 2018, 3:27 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

In a sense, that's kind of like WordPress 'short codes'.

12 Oct 2018, 8:24 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Support for Boilerplate HTML Chunks

swguy:

You can use my instructions:
https://www.thatsoftwareguy.com/zencart_php_in_description.html

I finally had a break to be able to revisit this thread and was going to recommend the same based on this other thread: https://www.zen-cart.com/showthread.php?117965-Boilerplate-mod-separate-it-from-description

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

13 Oct 2018, 11:52 AM
#6
lloyd_borrett avatar

lloyd_borrett

Zen Follower

Join Date:
Mar 2006
Location:
Rosebud, Victoria, Australia
Posts:
308
Plugin Contributions:
2

Re: Support for Boilerplate HTML Chunks

I don't know what WordPress 'short codes' are, or how they work, so can't comment.

The solution from swguy seems to have a lot of limitations and would be difficult for many to use.

The solution I have in mind is to have a table in which you can create, edit and delete chunks of HTML. Then the chunk names can be used to put the chunks into product descriptions. They can be anywhere in the descriptions.

When and wherever a product description is used, all chunks are expanded. Thus the full description with chunks is always the source for things like displaying the full description, displaying the first x characters of the description in short descriptions, searching for something, adding the full description to the Google Product Feed.

Within the Etomite CMS the use of chunks was so powerful I would even define the name of things like the short company name, full legal company name, postal address, street address, phone number, and email address in chunks and use them everywhere. Changing the chunk contents would change these values globally across the whole website.

Support for chunks could even be expanded to other fields like the product name, meta titles, meta descriptions, etc.

The concept of chunks of HTML and snippets of PHP code lives on in the MODX CMS, which is a successful fork of Etomite.
Chunks - https://docs.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/chunks
Snippets - https://docs.modx.com/revolution/2.x/developing-in-modx/basic-development/snippets

Adding supports for chunks to Zen Cart would make maintaining product descriptions much easier. Adding support for snippets to Zen Cart would make it the most powerful e-commerce tool available.

Zen Cart 1.5.5e, PHP 5.3.29 MySQL 5.5.42

13 Oct 2018, 7:10 PM
#7
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: Support for Boilerplate HTML Chunks

The solution from swguy seems to have a lot of limitations and would be difficult for many to use.
Not in my opinion.
I have been using them for years, based on this example, in two languages. 300 boilerplate strings and no problem.
I just put the foreach in a function to make the code chunks even simpler.
If you want a nice admin interface to edit them, that is something else, but I edit the string list files directly with a text edit, pasting in full html, no problems apart from having to escape some quotation marks.
For me this functionality is essential.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

13 Oct 2018, 10:07 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

torvista:

For me this functionality is essential.

You're welcome. Glad it helps you.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

14 Oct 2018, 2:50 PM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

lloyd_borrett:

The solution from swguy seems to have a lot of limitations and would be difficult for many to use.

The solution I have in mind is to have a table in which you can create, edit and delete chunks of HTML.

This is a closely guarded secret, so don't tell anyone - it will just be between you & me:

<whisper> You can hire me to write software to your precise specifications. </whisper>

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Oct 2018, 3:24 PM
#10
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,187
Plugin Contributions:
0

Re: Support for Boilerplate HTML Chunks

Gotta LOVE when a Florida Gator “whispers” instead of BITES !!!

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

17 Oct 2018, 2:25 AM
#11
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,846
Plugin Contributions:
0

Re: Support for Boilerplate HTML Chunks

lloyd_borrett:

I don't know what WordPress 'short codes' are, or how they work, so can't comment.
well, you did a pretty good job basically describing Wordpress shortcodes

Mike
AEIIA - Zen Cart Certified & PCI Compliant Hosting
The Zen Cart Forum...Better than a monitor covered with post-it notes!

17 Oct 2018, 9:56 AM
#12
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

There's a WordPress shortcode for Zen Cart products, btw:
https://wordpress.org/plugins/product-display-for-zen-cart/

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

13 Dec 2021, 2:55 PM
#13
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Support for Boilerplate HTML Chunks

The Boilerplate mod has been updated, for those who might be interested:

https://www.thatsoftwareguy.com/zencart_boilerplate_in_description.html

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.