Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 34
  1. #11
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Confirmation: can't use php in Product Descriptions?

    Excellent! Looks like maximized flexibility and utility to me :)

  2. #12
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    Quote Originally Posted by swguy View Post
    Here's the new tip: adding boilerplate files to your descriptions.

    http://www.thatsoftwareguy.com/zenca...ate_files.html

    I wrote some logic to do it automatically based on product id or category id, but I came back to doing it this way because it's the most flexible.
    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!

  3. #13
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    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:

    Code:
     <!--bof Product description -->
    <?php if ($products_description != '') { ?>
    <div><?php echo stripslashes($products_description) ?><br/><br/>
    Change this to:

    Code:
     <!--bof Product description -->
    <?php if ($products_description != '') { ?>
    <div><?php echo eval(stripslashes('?>'.$products_description)); ?><br/><br/>
    ...and now php include works. You can do something like this, for a product description:

    Code:
     <?php include('includes/languages/english/MyFolder/MyProduct.html'); ?>

  4. #14
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    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.

  5. #15
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    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:
    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);
    ...with:
    Code:
    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);
    includes/templates/CUSTOM/templates/tpl_modules_products_all_listing.php

    replace:
    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>'));
    ...with:
    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.

  6. #16
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,536
    Plugin Contributions
    127

    Default Re: Confirmation: can't use php in Product Descriptions?

    Quote Originally Posted by karma-lab View Post
    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.
    I added a brief treatment of this topic.

    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.
    Your application of this technique is sui generis. Everyone else just wanted boilerplate. Nevertheless, I added this suggestion too.

    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.

  7. #17
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    Quote Originally Posted by swguy View Post
    Your application of this technique is sui generis. Everyone else just wanted boilerplate. Nevertheless, I added this suggestion too.
    When I was searching for ways to use php include on product descriptions, I found several other threads of people wanting to do this exact same thing. So I don't think it's necessarily that unique. But thanks for your help.

  8. #18
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Confirmation: can't use php in Product Descriptions?

    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.

  9. #19
    Join Date
    Apr 2008
    Posts
    133
    Plugin Contributions
    1

    Default Re: Confirmation: can't use php in Product Descriptions?

    Quote Originally Posted by DrByte View Post
    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.
    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.

  10. #20
    Join Date
    May 2005
    Posts
    50
    Plugin Contributions
    0

    Default Re: Confirmation: can't use php in 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
    Attached Files Attached Files

 

 
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. How to use a append query to update all product descriptions?
    By welshop.com in forum General Questions
    Replies: 7
    Last Post: 24 Aug 2016, 12:33 PM
  2. v138a PHP 5.4.4 dropping product descriptions
    By LittelBird in forum Upgrading from 1.3.x to 1.3.9
    Replies: 7
    Last Post: 29 Jul 2014, 04:20 AM
  3. v151 Can I use custom html files to add extra info to my product descriptions?
    By Razzinator in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 16 Mar 2013, 06:29 PM
  4. Is it possible to use php coded links in category descriptions?
    By timps in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 1 Sep 2007, 01:52 AM
  5. Using php include in product descriptions
    By gaekwad in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 12 Jun 2007, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg