Excellent! Looks like maximized flexibility and utility to me :)
Excellent! Looks like maximized flexibility and utility to me :)
Thanks a bunch for figuring out how to do this. It works great for what I wanted to do, which is edit my product descriptions in a dedicated HTML editor and simply upload them as files to a directory on my site.
In fact, you might want to consider editing your explanation of the article on your site, because it still seems to imply that the use is to *add* repetitive boilerplate chunks to existing product descriptions, when it would be useful to mention that another use of it is to grab each product description *in full* from a file that you can edit and upload from another application, such as a dedicated HTML editor.
Thanks again!
As an alternative, I actually just figured out how to allow the use of php inside Product Descriptions (after reading a thread about how to allow the use of php inside ez pages).
Inside your tpl_product_info_display.php file, near the middle you will find:
Change this to:Code:<!--bof Product description --> <?php if ($products_description != '') { ?> <div><?php echo stripslashes($products_description) ?><br/><br/>
...and now php include works. You can do something like this, for a product description:Code:<!--bof Product description --> <?php if ($products_description != '') { ?> <div><?php echo eval(stripslashes('?>'.$products_description)); ?><br/><br/>
Code:<?php include('includes/languages/english/MyFolder/MyProduct.html'); ?>
Of course, there's always a "fly in the ointment" - a problem with both of the methods discussed here (the HTML_INCLUDE method, and the php include), is that, if you want to use it for your whole product description, then it only works on the product info page, but not the piece of the product info description that is normally parsed and used in the category pages, the featured products list, the specials list, etc.
With the HTML_INCLUDE method, you actually see that phrase 'HTML_INCLUDE_DVD' as the complete product description in the products list(s).
With the php include modification, you get nothing in the product lists. I guess with the php include method, you would need to modify several other template files as well if you want the text of your product description to appear there. I'm going to look into that.
I just finished getting the php include concept to work on all the various pages (featured, specials, new products etc.)
The basic idea is to eval() the product description first into a variable (using output buffering), and then perform whatever string cleaning and truncation is normally done on the results of that eval(). It's basically the same mod in each spot, just sometimes the code or variables are a bit different.
I'm not going to detail each mod, because this was a bunch of work and I'm not sure anyone really wants to go through this, it will be extremely helpful for *me*, but maybe not for anyone else to work in this fashion. But here's the basic idea:
includes/templates/CUSTOM/common/tpl_tabular_display.php
replace:
...with:Code:$list_box_contents[$rows]['description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
includes/templates/CUSTOM/templates/tpl_modules_products_all_listing.phpCode:ob_start(); eval(stripslashes('?>'.zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))); $contents = ob_get_contents(); ob_end_clean(); $list_box_contents[$rows]['description'] = zen_trunc_string(zen_clean_html($contents), PRODUCT_LIST_DESCRIPTION);
replace:
...with:Code:$disp_text = zen_get_products_description($products_all->fields['products_id']); $disp_text = zen_clean_html($disp_text); $display_products_description = stripslashes(zen_trunc_string($disp_text, PRODUCT_ALL_LIST_DESCRIPTION, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
Code:$disp_text = zen_get_products_description($products_all->fields['products_id']); ob_start(); eval(stripslashes('?>'.$disp_text)); $contents = ob_get_contents(); ob_end_clean(); $contents = zen_clean_html($contents); $display_products_description = zen_trunc_string($contents, PRODUCT_ALL_LIST_DESCRIPTION, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>');
includes/templates/CUSTOM/templates/tpl_modules_products_featured_listing.php
includes/templates/CUSTOM/templates/tpl_modules_products_new_listing.php
includes/templates/CUSTOM/templates/tpl_specials_default.php
...these are all virtually identical to the one above for products_all_listing.
One caveat: I'm already using a custom theme that has some modifications, so I cannot guarantee that this will match 100%. But the concept behind it is clear, for anyone who understands a bit of php.
Hope that helps anyone who wants to have the freedom of having every single product description reside on the server as a separate HTML file.![]()
I added a brief treatment of this topic.
Your application of this technique is sui generis. Everyone else just wanted boilerplate. Nevertheless, I added this suggestion too.In fact, you might want to consider editing your explanation of the article on your site, because it still seems to imply that the use is to *add* repetitive boilerplate chunks to existing product descriptions, when it would be useful to mention that another use of it is to grab each product description *in full* from a file that you can edit and upload from another application, such as a dedicated HTML editor.
Good luck,
Software Guy
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.
You could also just use a simple script to read all your description files en masse and insert them into the database as the product descriptions. A lot less touching of core code that way. But that would require you to click a link in the admin area to read them in.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
Thanks for the suggestion, but I know some php whereas I know next to nothing about mySQL. And the potential of screwing up the database always scares me. So this way works pretty good for me. I've been using it today and the amount of time it has been saving me while adding products and tweaking layouts and CSS is amazing. It would be nice to make this change in a future version of Zencart, it seems not so difficult. The way I did it above still works for normal product descriptions.
How can I get the HTML or php includes to work with the tabbed products light mod?
I tried both mods in the tpl_product_info_display.php file, and neither worked.
I have attached the tpl_tabbed_products_lite.php file, but I deleted the javascript check and the header to make it fit the filesize requirements.
Any help would be great because I have 70 products with the same pricing description that I would like to update once, not 70 times.
Thanks in advance!
Rod