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

    Default Re: Using php in Category descriptions

    You could use a version of swguy's boilerplate code to evaluate some PHP and substitute its output for a placeholder in the description output.

  2. #12
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using php in Category descriptions

    Adapted from swguy's boilerplate tips on his site (referenced in http://www.zen-cart.com/forum/showthread.php?t=120888):

    /includes/templates/custom/templates/tpl_product_info_display.php

    Change
    PHP Code:
     <!--bof Product description -->
    <?php if ($products_description != '') { ?>
    <div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
    <?php ?>
    <!--eof Product description -->
    to
    PHP Code:
     <!--bof Product description -->
    <?php if ($products_description != '') { ?>
    <?php 
    $php_content 
    '';//build content to be substituted for PHP_SUB in description
    if ($featured_products->RecordCount() > 0) {
      for (
    $i 0$i $featured_products->RecordCount(); $i++) {
        
    $php_content .= '<div class="categoryListBoxContents" style="width:33%;">';
        
    $php_content .= '<a href="' zen_href_link(FILENAME_DEFAULT'main_page=product_info&products_id=' $featured_products->fields['products_id']) . '">';
        
    $php_content .= zen_get_products_image($featured_products->fields['products_id']);
        
    $php_content .= '</a></div>';     
      } 
    }
    $products_description str_replace('PHP_SUB'$php_content$products_description);

    ?>
    <div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
    <?php echo stripslashes($stripped_products_description); ?></div>
    <?php ?>
    <!--eof Product description -->

  3. #13
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using php in Category descriptions

    The above follows from the boilerplate discussion for the product info page; it would be a different file and slightly different code for the category listing page, but the same principle applies.

  4. #14
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Using php in Category descriptions

    Thanks for the reply, I am not that great with PHP and got a little confused trying it

  5. #15
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using php in Category descriptions

    /includes/templates/your_template/templates/tpl_index_categories.php
    PHP Code:
    <?php
    // **********insert boilerplate code here to substitute in description**********
    // categories_description
        
    if ($current_categories_description != '') {
    ?>
    <div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description;  ?></div>
    <?php // categories_description 
    ?>
    <!-- BOF: Display grid of available sub-categories, if any -->
    Last edited by gjh42; 26 Sep 2010 at 08:57 PM.

  6. #16
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using php in Category descriptions

    Better description of method:
    PHP Code:
    <?php
    // categories_description
    if ($current_categories_description != '') {
      
    $php_content '';//build content to be substituted for PHP_SUB in description

      
    $php_content .= 'whatever code you need to determine the substituted content for this category';  
        
      
    $current_categories_description str_replace('PHP_SUB'$php_content$current_categories_description);
    ?>
    <div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description;  ?></div>
    <?php // categories_description ?>

  7. #17
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Using php next to Category descriptions

    This looks really useful but what if I just wanted it to pull the actual content from the database that doesn't have php?

  8. #18
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using php next to Category descriptions

    You need some PHP code to run a SQL query or otherwise determine the information that is going to be added. What content do you want to fetch from the db?

  9. #19
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Using php next to Category descriptions

    wow, i spent at least 6 hours playing around with the coding (should prob start learning PHP) but that worked great.

    As always, thanks for the help.

  10. #20
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Using php next to Category descriptions

    Quote Originally Posted by gjh42 View Post
    You need some PHP code to run a SQL query or otherwise determine the information that is going to be added. What content do you want to fetch from the db?
    I already have the mysql coding setup in the header.php file of the file. Pretty much I want take the results of that query and output it as displayed in post 1.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v154 Adding a Next Order Button in orders.php to see the next order
    By riolas in forum Managing Customers and Orders
    Replies: 3
    Last Post: 17 Jun 2016, 03:07 PM
  2. PHP: Help Using If Statement To Check Category?
    By joomoo79 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Jan 2010, 08:22 AM
  3. 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
  4. 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
  5. Category Descriptions displayed along-side Category Images.
    By roadhead in forum Templates, Stylesheets, Page Layout
    Replies: 18
    Last Post: 14 Nov 2006, 02:43 PM

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