Results 1 to 10 of 393

Hybrid View

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

  2. #2
    Join Date
    Sep 2008
    Posts
    97
    Plugin Contributions
    0

    Default Re: Smart Backgrounds support

    Hi Glen,

    I was wondering if I could change the background for a specific Product ID (and not just its SubCategory)?

    Let's say my SubCategory ID is 10_36 and my product ID is 196, what would be the right way to call it? (if that's even possible).

    I tried what seemed the most logical (at least, to me):
    .smartBG_10_36_196 #navColumnOne {background-image: url(../images/smartBG_10_36_196.gif);}
    and
    .smartBG_10_36&products_id=196 #navColumnOne {background-image: url(../images/smartBG_10_36&products_id=196.gif);}

    No luck with those 2...

    Any advice?

    Thanks

    Damien

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

    Default Re: Smart Backgrounds support

    Smart Backgrounds is not built to distinguish individual products. The first rule you show would not function for you in SBG, and the second one is not a valid stylesheet selector or URL.

    It would be easy to modify the function code to look for product images instead of or in addition to category images.
    You could also use a simple test in your tpl_main_page.php, something like
    PHP Code:
    <?php 
    $smart_image 
    smart_backgrounds();
    if (
    $current_page_base == 'product_info' and $_GET['products_id'] == '196'$smart_image '_p196';
    ?>

    <body id="<?php echo $body_id 'Body'?>" class="smartBG<?php echo $smart_image;?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'?>>
    This is hard-coded for one product; if you want it to dynamically check for product images, I will post the code for that.

    The CSS would be like
    Code:
    .smartBG_p196 #navColumnOne {background-image: url(../images/whatever.gif);}

  4. #4
    Join Date
    Sep 2008
    Posts
    97
    Plugin Contributions
    0

    Default Re: Smart Backgrounds support

    Glen,

    Thanks for your speedy reply.

    To have the code for a dynamic check of product images would be awesome!
    I do have several products I'd like to attribute a specific background to. That would be must faster than copy/paste your code and change the ID number for each product... plus, that would make more sense for future use.

    I cannot count the amount of times you have help me.
    Thanks,

    Damien

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

    Default Re: Smart Backgrounds support

    OK, here's a multi-multi-stacking version. It first checks for an individual product image, then for a generic '_product_info' image, then for category images as before. Replace the entire content of smart_backgrounds_functions.php with this. Save the original file elsewhere first as a backup.
    PHP Code:
    <?php
    /**
     * @package templateSystem
     * @copyright Copyright 2010 Glenn Herbert
     * @copyright Portions Copyright 2003-2007 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * /includes/functions/extra_functions/smart_backgrounds_functions.php  gjh42  2010-02-10   test 2010-02-17
     * Smart Backgrounds   by Glenn Herbert (gjh42)
     *
     * Call this function from any file where page-dependent coding is desired.
     * $smart_image = smart_backgrounds();
     * Include string arguments if you want to use other than '.gif' images or look for other than 'bg' files.
     * $smart_image = smart_backgrounds('.jpg','sidebox'); //returns '_23' if smartsidebox_23.jpg exists
     * Use the value of $smart_image to set a classname, filename or other event management when a corresponding image file exists.
     */

    function smart_backgrounds($ext='.gif'$location='bg'){
      
    $smart_image '';
      if (
    $_GET['main_page'] == 'index' or $_GET['main_page'] == 'product_info') { 
        
    // _p and products_id  only if individual prod bg image exists, else  _product_info  only if page bg image exists, else  _ and cPath  only if individual cat bg image exists, else  _ and top cat id  only if top cat bg image exists
        
    $smart_image = ($_GET['main_page'] == 'product_info' and file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_p' $_GET['products_id'] . $ext))?'_p' $_GET['products_id']:(($_GET['main_page'] == 'product_info' and file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_product_info' $ext))?'_product_info':
                       (
    file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_' $_GET['cPath'] . $ext)?'_' $_GET['cPath']:(file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_' . (int)$_GET['cPath'] . $ext)?'_' . (int)$_GET['cPath']:'')));
      } elseif (
    $_GET['main_page'] == 'page') { // _page and ez-page id  only if ez-page id bg image exists, else  _page  only if general ez-page bg image exists
        
    $smart_image file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_page' $_GET['id'] . $ext)?'_page' $_GET['id']:(file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_page' $ext)?'_page':'');
      } else { 
    // _ and page base only if page bg image exists
        
    $smart_image file_exists(DIR_WS_TEMPLATE_IMAGES 'smart' $location '_' $_GET['main_page'] . $ext)?'_' $_GET['main_page']:''//if no images are found $smart_image will be blank
      
    }
      return 
    $smart_image;
    ?>
    Let me know how this works, and I will adjust if needed.

    Oh yes, name the images like smartbg_p123.gif or smartbg_product_info.gif.
    Last edited by gjh42; 17 Feb 2010 at 08:43 PM.

  6. #6
    Join Date
    Sep 2008
    Posts
    97
    Plugin Contributions
    0

    Default Re: Smart Backgrounds support

    Glenn,

    I wasn't expecting that much that fast! Thanks!

    I guess it's a great time to upgrade... I only have the 2.1.1 (No smart_backgrounds_functions.php in that version).
    I will get back to you as soon as the v.3.0.1 is in place and the mod added.

    Thanks again!

    Damien

  7. #7
    Join Date
    Sep 2008
    Posts
    97
    Plugin Contributions
    0

    Default Re: Smart Backgrounds support

    Glenn,



    It works like a charm.

    Thank you soooo much for your help!

    Damien

 

 

Similar Threads

  1. Adding Image Map to header with Smart Backgrounds
    By cspan27 in forum Addon Templates
    Replies: 16
    Last Post: 25 Jul 2009, 01:14 AM
  2. smart backgrounds
    By Glendon in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 11 Sep 2008, 04:49 PM
  3. Backgrounds
    By v.kirk in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 23 Jun 2006, 06:14 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