Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    7
    Plugin Contributions
    0

    Default adding product model into side boxes

    i'd like to add the product model in the "special products" sidebox.
    someone can tell me a way to do it? or just which files i shouild edit?
    thanx
    jouba

  2. #2
    Join Date
    Jan 2009
    Posts
    7
    Plugin Contributions
    0

    Default Re: adding product model into side boxes

    Dunno i fanybody is interested, but i solved my issue so i'm posting it:
    in the file featured.php you need to modify the query in the following way:
    $random_featured_products_query = "select p.products_id, p.products_image, p.products_model,pd.products_name,
    p.master_categories_id

    then you need to add some code in the file tpl_featured.php as below:
    $content .= '<br />' . $random_featured_product->fields['products_name'] .'<br />'.$random_featured_product->fields['products_model'].'</a>';

  3. #3
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,821
    Plugin Contributions
    2

    Default Re: adding product model into side boxes

    Thanks for posting solution..am sure it will help other
    zencart forum members

  4. #4
    Join Date
    Feb 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: adding product model into side boxes

    Quote Originally Posted by jouba View Post
    Dunno i fanybody is interested, but i solved my issue so i'm posting it:
    in the file featured.php you need to modify the query in the following way:
    $random_featured_products_query = "select p.products_id, p.products_image, p.products_model,pd.products_name,
    p.master_categories_id

    then you need to add some code in the file tpl_featured.php as below:
    $content .= '<br />' . $random_featured_product->fields['products_name'] .'<br />'.$random_featured_product->fields['products_model'].'</a>';
    I have a cusom field for short description like two words or so and would like to figure out how to insert that below the Featured Product listings. Tried to adapt the above to work with the custom field but it doesn't show up. I am assuming that I need to define or select the custom field value somewhere to make it available, but can't see where that is....

    Anyone have any insight on this?

  5. #5
    Join Date
    Feb 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: adding product model into side boxes

    Okay... I figured it out... it's in includes/functions/functions_lookups.php:

    I put mine in around line 360 but I think it can go most anywhere as long as it's done right...
    Code:
    /*
     * Your note if you want one
     * Grab custom value
     */
      function zen_get_products_customfield($product_id) {
        global $db;
    
        $product_query = "select p.products_customfield
                          from " . TABLE_PRODUCTS . " p
                          where p.products_id = '" . (int)$product_id . "'";
    
        $product =$db->Execute($product_query);
    
        return $product->fields['products_customfield'];
      }
    Obviously you should replace customfield with the actual name of your field... should work with any custom field...

    Then I used this:
    Code:
        $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    	$content .= '<div class="centeredContent">' . zen_get_products_binding($random_featured_product->fields['products_id']). '</div>';
        $content .= '<div>' . $featured_box_price . '</div>';
        $content .= '</div>';
    in the tpl_featured.php file....

    Plan to do this throughout including main Features, New Products, Specials...

    Yay for Open Source!!

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: adding product model into side boxes

    There are two neat little function in the functions_lookups that will pull any field that you want from the products or products_description tables by just passing it the products_id ... and for pulling any field from the categories and categories_description tables ...

    For products:
    Code:
    /*
     * Return any field from products or products_description table
     * Example: zen_products_lookup('3', 'products_date_added');
     */
      function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $product_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                  where p.products_id ='" . (int)$product_id . "'
                                  and pd.language_id = '" . (int)$language . "'");
    
        $return_field = $product_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    For categories:
    /*
    * Return any field from categories or categories_description table
    * Example: zen_categories_lookup('10', 'parent_id');
    */
    function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
    global $db;

    if (empty($language)) $language = $_SESSION['languages_id'];

    $category_lookup = $db->Execute("select " . $what_field . " as lookup_field
    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
    where c.categories_id ='" . (int)$categories_id . "'
    and cd.language_id = '" . (int)$language . "'");

    $return_field = $category_lookup->fields['lookup_field'];

    return $return_field;
    }
    However, there is a little bug in these that you will want to update:

    For products:
    Code:
    /*
     * Return any field from products or products_description table
     * Example: zen_products_lookup('3', 'products_date_added');
     */
      function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $product_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                  where p.products_id ='" . (int)$product_id . "'
                                  and pd.products_id = p.products_id
                                  and pd.language_id = '" . (int)$language . "'");
    
        $return_field = $product_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    For categories:
    Code:
    /*
     * Return any field from categories or categories_description table
     * Example: zen_categories_lookup('10', 'parent_id');
     */
      function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $category_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                  where c.categories_id ='" . (int)$categories_id . "'
                                  and c.categories_id = cd.categories_id
                                  and cd.language_id = '" . (int)$language . "'");
    
        $return_field = $category_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. model appearing on side boxes
    By jouba in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Jan 2009, 01:54 PM
  2. Side boxes run into header
    By webd in forum General Questions
    Replies: 8
    Last Post: 7 Sep 2008, 06:08 AM
  3. Adding banner exchange code into blank side boxes
    By kapearl in forum Addon Sideboxes
    Replies: 1
    Last Post: 18 Jul 2007, 12:48 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