Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Using php next to Category descriptions

    I'm trying to run a block of PHP code on the category descriptions page. I set this to be the categories description but it doesn't seem to execute, it just displays it instead. Can anyone help? Here is the code:

    PHP Code:
    <?php  
     
    if ($featured_products->RecordCount() > 0) {
       for (
    $i 0$i $featured_products->RecordCount(); $i++) {
       echo 
    '<div class="categoryListBoxContents" style="width:33%;">';
       echo 
    '<a href="' zen_href_link(FILENAME_DEFAULT'main_page=product_info&products_id=' $featured_products->fields['products_id']) . '">';
       echo 
    zen_get_products_image($featured_products->fields['products_id']);
       echo 
    '</A></div>';     

    ?>

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Using php in Category descriptions

    I'm trying to run a block of PHP code on the category descriptions page.
    I believe that only html is allowed in the description block

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

    Default Re: Using php in Category descriptions

    I don't understand what you're trying to do with the code you posted.
    .

    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.

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

    Default Re: Using php in Category descriptions

    Quote Originally Posted by DrByte View Post
    I don't understand what you're trying to do with the code you posted.
    I forgot to post up the MySQL coding that I put in header.php

    PHP Code:
       $featured_products_query "SELECT feature.products_id, product_info.products_image, product_info.products_price, product_desc.products_name FROM " TABLE_FEATURED " as feature, " TABLE_PRODUCTS " as product_info, " .  TABLE_PRODUCTS_DESCRIPTION " as product_desc, " TABLE_PRODUCTS_TO_CATEGORIES " as ptc WHERE feature.products_id = product_info.products_id AND feature.products_id = product_desc.products_id and feature.products_id = ptc.products_id AND ptc.categories_id = :categoriesID ORDER BY rand() LIMIT 3";
       
    $featured_products_query $db->bindVars($featured_products_query':categoriesID'$current_category_id'integer');

       
    $featured_products $db->Execute($featured_products_query); 
    Essentially, look at featured products for all products within a given category (the category that the user is looking at). Select three at random and return the row values as defined above. (Product ID, image, price, and name).

    The code in the original post, generally cycles through the data and returns the row values for it.

  5. #5
    Join Date
    Jun 2003
    Posts
    33,721
    Plugin Contributions
    0

    Default Re: Using php in Category descriptions

    Doesn't the Featured Products block already do that?
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

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

    Default Re: Using php in Category descriptions

    So essentially, an additional featured centerbox but inside the description. Why don't you want to use the regular featured centerbox (set to three products)?

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

    Default Re: Using php in Category descriptions

    Quote Originally Posted by gjh42 View Post
    So essentially, an additional featured centerbox but inside the description. Why don't you want to use the regular featured centerbox (set to three products)?
    I actually forgot that was there but wanted to embed it in the description along with some other stuff.

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

    Default Re: Using php in Category descriptions

    Quote Originally Posted by gjh42 View Post
    So essentially, an additional featured centerbox but inside the description. Why don't you want to use the regular featured centerbox (set to three products)?
    To further:

    - I used the center box but it doesn't randomly select three products, it just selects the first three available.
    - The parent category is show for the header, not the child where it's located.
    - The configuration places the center box below the product listing, not above where I'm trying to get it to show. (I know how to fix this one but was hoping on something not involving me ripping into ZenCart too much).

    Is an example: http://www.justuptowngames.com/index...x&cPath=1_2_61

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

    Default Re: Using php in Category descriptions

    I too am also looking to use PHP in my categories description but for different reason. Can this be done?

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

    Default Re: Using php in Category descriptions

    What retched is doing is not actually including PHP *in* the category descriptions, but rather including additional content to be displayed via the template directly above/below the category description when the category description is displayed.

    You can do the same simply by altering your template files as needed.

    However, embedding PHP code into the actual HTML of the category description via your admin is NOT supported in Zen Cart.
    .

    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.

 

 
Page 1 of 3 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