Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Custom Product Page - for particular product - use separate template

    is it possible to use a separate template for a particular product but all others use default?

    such as item-123 uses product template abc123.tpl but all others use standard

    thanks
    peace

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Custom Product Page - for particular product - use separate template

    You can style the product whose product_id value is 123 differently from all other products by creating a p_123.css file in your custom template's css directory (/includes/templates/YOUR_TEMPLATE/css/p_123.css).

  3. #3
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: Custom Product Page - for particular product - use separate template

    thanks

    thing is, i gotta change the content there too
    peace

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Custom Product Page - for particular product - use separate template

    You could create the file /includes/templates/YOUR_TEMPLATE/product_info/extra_main_template_vars/product_123.php:

    Code:
    <?php
    if (((int)$_GET['products_id']) == 123) {
      // Retrieve any special stuff you need from the database
      $tpl_page_body = 'tpl_product_info_display_123.php';  // Use the file /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display_123.php to format this special product's information
    }
    You will probably need the p_123.css file, too ...

  5. #5
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: Custom Product Page - for particular product - use separate template

    Quote Originally Posted by lat9 View Post
    You could create the file /includes/templates/YOUR_TEMPLATE/product_info/extra_main_template_vars/product_123.php:

    Code:
    <?php
    if (((int)$_GET['products_id']) == 123) {
      // Retrieve any special stuff you need from the database
      $tpl_page_body = 'tpl_product_info_display_123.php';  // Use the file /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display_123.php to format this special product's information
    }
    You will probably need the p_123.css file, too ...
    wow, nice!

    i'd need to exclude the default pricing and other stuff as well cuz this is a customized product that goes beyond the cart capability presently

    think i could tweak the default template call kinda like this:

    Code:
    <?php
    if (((int)$_GET['products_id']) == 123) {
      // use special template
      $tpl_page_body = 'tpl_product_info_display_123.php';  
      // Use the file /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display_123.php 
      //to format this special product's information
    } else {
    // use normal template
    {
    // normal product template code here
    }
    };
    peace

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Custom Product Page - for particular product - use separate template

    The normal template (tpl_product_info_display.php) will have already been set into the $tpl_page_body variable by /includes/modules/pages/product_info/main_template_vars.php's processing. All you need to do in your override is to set the name of the template file that will process that special product (and edit the special product's template file to do what you want).

  7. #7
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: Custom Product Page - for particular product - use separate template

    i think i see the spot, around the following location:

    Code:
      if ( $res->fields['total'] < 1 ) {
    
        $tpl_page_body = '/tpl_product_info_noproduct.php';
    
      } else {
    
        $tpl_page_body = '/tpl_product_info_display.php';
    peace

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

    Default Re: Custom Product Page - for particular product - use separate template

    If you follow lat9's suggestion, you won't need to touch the stock main_template_vars.php at all - always a good thing to avoid editing existing files when you can make a new one that will allow for upgrades without having to maintain/merge stock files.

  9. #9
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: Custom Product Page - for particular product - use separate template

    Quote Originally Posted by gjh42 View Post
    If you follow lat9's suggestion, you won't need to touch the stock main_template_vars.php at all - always a good thing to avoid editing existing files when you can make a new one that will allow for upgrades without having to maintain/merge stock files.
    All you need to do in your override is to set the name of the template file that will process that special product (and edit the special product's template file to do what you want).
    I guess I'm not sure how to do the override

    I've figured out some other override stuff but not sure about this one
    peace

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

    Default Re: Custom Product Page - for particular product - use separate template

    You could create the file /includes/templates/YOUR_TEMPLATE/product_info/extra_main_template_vars/product_123.php:
    I haven't used this variant of override directories myself, but I believe if you simply make that file with just the content shown and put it in that folder path, Zen Cart will automatically detect and use it in the appropriate circumstances (product 123's info page).

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Can I literally use SEPARATE images as a thumbnails in multiple product photos?
    By sportbiker in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 27 Nov 2014, 08:53 AM
  2. Particular product visible to a particular group only
    By aditya369 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 19 Apr 2012, 07:47 AM
  3. Custom link for a product to use Amazon Affiliate Program?
    By stargatesam in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 28 Jan 2010, 04:16 PM
  4. Disable a particular sidebox for a particular page?
    By surabisantosh in forum Basic Configuration
    Replies: 1
    Last Post: 22 Nov 2007, 08:04 PM
  5. Separate product prices per customer for each product?
    By paradoxbox in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 13 Aug 2006, 08:15 PM

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