Forums / All Other Contributions/Addons / Smart Backgrounds support

Smart Backgrounds support

Views: 55,899

Results 301 to 320 of 393
10 Feb 2010, 10:15 PM
#301
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Smart Backgrounds support

Either you have a foreground image for your logo, or background images. Switching background images will not hide the foreground image - the different background images will be there, covered by the foreground image.
You can set the normal logo as a background image for #logo, so it will show when there is no special image.

It looks like the logo is taking its height and width from pixel_trans.gif. This may mean that you have not defined height and width in /includes/languages/english/your_template/header.php.

10 Feb 2010, 10:29 PM
#302
crunch avatar

crunch

Zen Follower

Join Date:
Mar 2009
Posts:
227
Plugin Contributions:
0

Re: Smart Backgrounds support

Thanks for your time. I'll hack away at this some more and see if I can figure it out.

11 Feb 2010, 2:40 AM
#303
crunch avatar

crunch

Zen Follower

Join Date:
Mar 2009
Posts:
227
Plugin Contributions:
0

Re: Smart Backgrounds support

OK. I've gone through this multiple times... Here is what I've got. Again, I just want the main website logo to change when going to specific categories.

/custom_template/css/stylesheet_smartbg.php:

#logo {background-image: url(../images/smartbg.gif);}

.smartBG_1 #logo {background-image: url(../images/smartbg_1.gif);}
.smartBG_4 #logo {background-image: url(../images/smartbg_4.gif);}
.smartBG_44 #logo {background-image: url(../images/smartbg_44.gif);}
.smartBG_103 #logo {background-image: url(../images/smartbg_103.gif);}
.smartBG_84 #logo {background-image: url(../images/smartbg_84.gif);}
.smartBG_36 #logo {background-image: url(../images/smartbg_36.gif);}

/includes/languages/english/custom_template/header.php (specified the width and height of each of the smartbg_ images):

define('HEADER_LOGO_WIDTH', '955');
define('HEADER_LOGO_HEIGHT', '90');
define('HEADER_LOGO_IMAGE', 'pixel_trans.gif');

/includes/templates/custom_template/common/tpl_main_page.php:

<body id="<?php echo $body_id . 'Body'; ?>" class="smartBG<?php echo smart_backgrounds();?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>>

The test images (smartbg_xx) have all been uploaded to /custom_template/images/

The problem:
There is no main website logo on homepage and there are no logos appearing when entering the specific categories.

What have I missed?:frusty:

17 Feb 2010, 4:43 PM
#306
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

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

17 Feb 2010, 5:31 PM
#307
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

<?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```
.smartBG_p196 #navColumnOne {background-image: url(../images/whatever.gif);}

17 Feb 2010, 6:02 PM
#308
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

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. :thumbsup:
Thanks,

Damien

17 Feb 2010, 7:37 PM
#309
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

<?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.
17 Feb 2010, 8:19 PM
#310
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

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

17 Feb 2010, 8:36 PM
#311
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

Re: Smart Backgrounds support

Glenn,

:thumbsup:

It works like a charm.

Thank you soooo much for your help!

Damien

10 May 2010, 7:05 PM
#312
mshutch avatar

mshutch

New Zenner

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
34
Plugin Contributions:
0

Re: Smart Backgrounds support

Just want to say thank you too Glenn!

Colleen

--Colleen

2 Aug 2010, 3:34 PM
#314
e81ny avatar

e81ny

New Zenner

Join Date:
Feb 2007
Location:
New York
Posts:
88
Plugin Contributions:
0

Re: Smart Backgrounds support

Hi, Does this work for the latest Zen cart version 1.3.9?
Thanks in advance.

12 Aug 2010, 3:43 PM
#315
so19firearms avatar

so19firearms

New Zenner

Join Date:
Nov 2009
Posts:
6
Plugin Contributions:
0

Re: Smart Backgrounds support

Great job on this add-on.
I've got the background's working more or less how I want them now
Example 1
Example 2

My question is now - Is it possible to re-create or use the banner functionality so that I can have a particular banner on any given page with maybe a blank pixel where I don't want a banner (i.e product pages)?
I'm guessing the foreground functionality is what I'm after now, but I have no clue where to insert the code....or what code to use, really.

Hope you can help

13 Aug 2010, 9:39 AM
#316
so19firearms avatar

so19firearms

New Zenner

Join Date:
Nov 2009
Posts:
6
Plugin Contributions:
0

Re: Smart Backgrounds support

Scratch that - The multi-multi-stacking version breaks the cart. It returns a blank page after you press "Add to cart" :(

15 Aug 2010, 7:53 PM
#317
acidztrip avatar

acidztrip

New Zenner

Join Date:
Aug 2010
Posts:
1
Plugin Contributions:
0

Re: Smart Backgrounds support

I also would like to know if this would work with 1.3.9 ? Incase anyone has already tried it... Thanks

17 Aug 2010, 2:15 AM
#318
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Smart Backgrounds support

I don't currently have a v1.3.9 test site, but I understand it does work except that there is a situation where it would not operate on two particular pages which have a customized version of tpl_main_page.php already (which will be used in preference to the version in the custom template folder). This is not a new situation, but has existed all along, in popup pages:

/includes/templates/template_default/popup_attributes_qty_prices/tpl_main_page.php
/includes/templates/template_default/popup_coupon_help/tpl_main_page.php

So unless you need to affect these pages, you should have no problem. If you do, there is one line to modify in tpl_main_page.php, described in the readme, and you can easily fix this yourself.

30 Aug 2010, 11:18 PM
#319
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

Re: Smart Backgrounds support

Glenn,

That's gonna sound stupid but I got a blank page when using the Paypal Express Checkout.
Since it seems related to Smart_Background... I thought that was the best place to ask for advices...

I checked the log and I get this:

[30-Aug-2010 18:58:18] 
PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: 
Cannot send session cache limiter - headers already sent 
(output started at /wheremyZCis/includes/functions/extra_functions/smart_backgrounds_functions.php:30) in /wheremyZCis/includes/functions/sessions.php on line 110

[30-Aug-2010 18:58:18] 
PHP Warning:  
Cannot modify header information - headers already sent by 
(output started at /wheremyZCis/includes/functions/extra_functions/smart_backgrounds_functions.php:30) in /wheremyZCis/includes/init_includes/overrides/init_templates.php on line 79

[30-Aug-2010 18:58:19] 
PHP Warning:  
Cannot modify header information - headers already sent by 
(output started at /wheremyZCis/includes/functions/extra_functions/smart_backgrounds_functions.php:30) in /wheremyZCis/includes/modules/payment/paypalwpp.php on line 1569

[30-Aug-2010 18:58:19] 
PHP Warning:  
Cannot modify header information - headers already sent by 
(output started at /wheremyZCis/includes/functions/extra_functions/smart_backgrounds_functions.php:30) in /wheremyZCis/includes/functions/functions_general.php on line 45

I have no clue why smart_backgrounds_functions.php would be involved in my issue and cannot for the life of me figure it out.

Any advice on where to look or what could be the issue?

If needed here is a link to my website:
www *DOT *looloos *HYPHEN *organics *DOT *com/index.php
Running 1.3.9d (I know, I know, I need to upgrade... )

Thanks in advance

Damien

31 Aug 2010, 4:23 PM
#320
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Smart Backgrounds support

The modified version of the file posted above only has 30 lines (the original mod version has 28 lines), so I expect there is an extra space after the closing ?> in line 30 of your copy of it. That can cause the PHP error you describe.