Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2008
    Location
    Ohio
    Posts
    21
    Plugin Contributions
    0

    Default Using PHP "include" in category & product description

    I have several product lines that come in kits of various configurations. Example: Product line 1 has 4 components, A, B, C, and D. Kit 1 includes A, B, and C. Kit Two includes A, B, and D. Kit 3 includes only A and D.
    I want to have a file with a detailed description of each component -lets say a_desc.php, b_desc.php and so on, so in the description of Kit 3 I could have

    <p> Kit 3 includes the following components:</p>
    <?php
    include("a_desc.php");
    include("d_desc.php");
    ?>

    That way I would only have to update the detailed description of a component in one place to have all kits updated.

    I've tried this with my _desc.php file located in a couple of different directories and changing the php include statement to use every possible combination of directory info from just filename all the way out to http://...filename, and nothing has worked.

    Questions:
    1. Can this be done without more trouble than its worth? (If not, the rest of the questions don't matter, but I'd appreciate alternate suggestions.)
    2. Where is the best place to put the -desc.php files to avoid troubles with permissions, and should they be .php or .html by name.
    3. Should they be a standard html file format internally, or does there need to be any PHP tags or code added?
    4. are the above example include statements the correct way to include these files in the description, or is there a better way? If these are the best way, any tips you could provide (especially regarding designating the path)would be appreciated.)
    Matthew G
    www.g6enterprises.com
    ZenCart 1.3.8a

  2. #2
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    6,173
    Plugin Contributions
    0

  3. #3
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,264
    Plugin Contributions
    3

    Default Re: Using PHP "include" in category & product description

    You cannot include PHP in the description text (or any component that is basically html that ZC parses into a page. This includes defined pages, EXZ pages and all description texts (product, category, etc)).

    The reason is that in the case of description text, the data is stored in the database. The core php cannot read the code BEFORE it is parsed - (because it simply isn't there to read). The data is brought into the compiled HTML page only AFTER all the php has done its work.

    As haredo indicates, there may be something you could achieve with the basic concept of boilerplate text... Talk to Scott Wilson (swguy) about this.
    20 years a Zencart User

  4. #4
    Join Date
    Nov 2008
    Location
    Ohio
    Posts
    21
    Plugin Contributions
    0

    Default Re: Using PHP "include" in category & product description

    Thanks much to both of you. Now I understand why it won't work the way I was trying to do it. If I'm understanding the other page referenced correctly, that's a good tip, but my product descriptions often contain lists and specification tables. I don't think the boilerplate text will help, unless I can put full HTML code in the string definition... would that work, or would it just show up in the description with the tags visible?
    Matthew G
    www.g6enterprises.com
    ZenCart 1.3.8a

  5. #5
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,264
    Plugin Contributions
    3

    Default Re: Using PHP "include" in category & product description

    You can insert most of the (basic) HTML tags into description text, and they will render the text (or content) as you would expect HTML to be rendered in a browser.

    Hyperlinks <a href=...>, Image Source Tags <img src=...>, Ordered Lists <ul><li>, font size, colour, etc, ect - - - will all show up correctly.

    Many people (myself included) construct such description text in external HTML editors, capture the code portions we want onto clipboard, then "paste" that code into the wysiwyg editor (after toggling to HTML mode).

    Remember, the text (html formatted or not) is STATIC, and will have to be altered manually.

    There may be a way to generate additional dynamic content using PHP, but this would need some thought - not only additional code in the template.php files, but probably additional fields in the database where you would manage the "associations" between the product data sets. So you would also need additional facilities in the product admin side as well (becomes complicated... !)
    20 years a Zencart User

 

 

Similar Threads

  1. Replies: 10
    Last Post: 14 Mar 2016, 12:03 PM
  2. include "includes/application_top.php" in "www/sub/sub.php"?
    By linjuming in forum General Questions
    Replies: 4
    Last Post: 23 Apr 2013, 06:12 AM
  3. NEWBIE: How do I position "description" on Featured & product listings?
    By hugozc in forum Templates, Stylesheets, Page Layout
    Replies: 13
    Last Post: 11 Feb 2012, 09:22 PM
  4. Using "table" shipping but need one category to be "Flat Rate"
    By GTHENRY in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 27 Apr 2011, 08:35 PM
  5. How to remove sub-category "featured products" & "category image"?
    By andrewcklau in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Jun 2010, 10:32 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR