Forums / All Other Contributions/Addons / Smart Backgrounds support

Smart Backgrounds support

Views: 55,899

Results 281 to 300 of 393
20 Jan 2010, 6:05 AM
#281
twaddle avatar

twaddle

Banned

Join Date:
Jul 2009
Location:
Prague, Czech Republic
Posts:
478
Plugin Contributions:
0

Smart Backgrounds support

gjh42:

Since you have done so much since you first posted, it is hard to tell what some of your comments refer to.
Sorry, yes, I realise that :D That's the trouble with the seven minute limit on editing sometimes :shocking:

gjh42:

TM templates are usually much harder to customize the style of, since they have lots of extra nested divs, sometimes tables, and renamed standard elements, sometimes with standard distinction abilities removed.
Tell me about it LOL. I'll take a look at the navCatTabsWrapper padding later today when I get time

Thanks for the reply Glenn, and it's a great little MOD btw

9 Feb 2010, 1:27 AM
#282
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

I've read most of the thread, and managed to get the foreground image code working, to vary between different logo foreground images. I've tried several times to replace the current code that is in tpl_header.php to get images to work with subcategories, using the bg image code, modified for use with foreground images and with .jpg

Base code (works, but no subcatagories)

if ($current_page_base == 'index' or $current_page_base == 'product_info') { //change filename to smartimg_ and top cat id only if cat image exists
  $smart_image = (file_exists(DIR_WS_TEMPLATE_IMAGES . 'smartimg_' . str_replace(strstr($_GET[cPath],'_'),'',$_GET[cPath]) . '.jpg'))?'smartimg_' . str_replace(strstr($_GET[cPath],'_'),'',$_GET[cPath] . '.jpg'):HEADER_LOGO_IMAGE;

Attempted code (no images show)

 if ($current_page_base == 'index' or $current_page_base == 'product_info') { //add _ and cPath to img filename only if individual cat img image exists, else add _ and top cat id to img filename only if top cat img image exists
  $smart_image = file_exists(DIR_WS_TEMPLATE_IMAGES . 'smartimg_' . $_GET[cPath] . '.jpg')?'_' . $_GET[cPath]:(file_exists(DIR_WS_TEMPLATE_IMAGES . 'smartimg_' . (int)$_GET[cPath] . '.jpg')?'_' . (int)$_GET[cPath]:'');

Any help or ideas would be most appreciated.

9 Feb 2010, 3:42 AM
#283
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

It looks like you are using code from v2.0 or earlier. This has been improved even in the currently available v2.1.1 to allow indifidual subcategory control, and v3.0 radically changes the method of use to be much simpler and more flexible.

With mod submissions and updates sometimes taking two months or more to be approved these days, I had forgotten that I had not actually submitted it yet, and the thread where I did attach the zip is obscure enough that only 33 people had downloaded from there. Since I have heard no questions from them about how to make it work, I will assume that they have not found any bugs, and proceed to submit the update. Until it is approved, I will move the attachment to this thread.

9 Feb 2010, 4:04 AM
#284
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

For the case of foreground image switching, this from the v3.0 readme tells how to use it:


To switch Foreground images instead of Backgrounds:

Call the smart_backgrounds() function from any file where page-dependent coding is desired.
Include string arguments if you want to use other than '.gif' images or look for other than 'bg' files.

<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'smartsidebox' . smart_backgrounds('.jpg','sidebox') . '.jpg', 'Your alt text');?>

will output

<img src="http://yourdomain.com/includes/templates/your_template/images/smartsidebox_page5.jpg" alt="Your alt text">

on ez-page id 5 if smartsidebox_page5.jpg exists. Combine this with an "if" statement

$smart_image = smart_backgrounds('.jpg','sidebox');
if ($smart_image == '_page5') {
echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'smartsidebox' . $smart_image . '.jpg', 'Your alt text');
}

to show the content only on ez-page id 5 if smartsidebox_page5.jpg exists.

if (substr_count($smart_image,'_page')) {
echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'smartsidebox' . $smart_image . '.jpg', 'Your alt text');
}

will show the content on any ez-page if an appropriate smartsidebox_page.jpg file exists.
Name and save images as described above.
For foreground images, you do not need to make individual stylesheet rules.

You could use```php

<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'smartlogo' . smart_backgrounds('.jpg','logo') . '.jpg', 'Your alt text');?>
with images like smartlogo_13_27.jpg to give a custom logo for subcategory cPath 13_27.
10 Feb 2010, 1:52 AM
#285
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

Glenn,

Thank you for the quick feedback. I'll check out the 3.0 code and make it work.

cfs

10 Feb 2010, 4:42 AM
#286
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

Still having a bit of trouble.

The images I am trying to vary are the logo images. Looking over the code in 3.0, I revised my branding section of tpl_header.php to include the following:

<!--bof-branding display-->

<tr align="right">
<td>


<div id="lwrapper">

<div id="logo">

<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'smartimg' . smart_backgrounds('.jpg','img') . '.jpg', HEADER_ALT_TEXT, HEADER_LOGO_WIDTH, HEADER_LOGO_HEIGHT) . '</a>'; ?></div>
    
<br class="clearBoth" />
</div>

</td>
</tr>


<!--eof-branding display-->

It hangs up the site completely. Something is not working with

smart_backgrounds('.jpg','img')

I've got it working with the function removed from the code.

10 Feb 2010, 5:52 AM
#287
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

Ok, it's not hanging up if the smart_backgrounds_functions is in the /includes/functions/extra_functions folder

if it is in
/includes/functions/extra_functions/mytemplate/

it hangs up.

Even so, while it is working, I cannot get it to report back a value other than null, regardless of the page I am on.

Color me confused.

10 Feb 2010, 8:00 AM
#288
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

What image names do you have, and where are they saved?
You do want a base image named (in this case) smartimg.jpg, for display when there is no specific image matching a page. If there is no match, the function will return null, and the base name and extension will be used.

There is no template override available in /includes/functions/, so
/includes/functions/extra_functions/smart_backgrounds_functions.php as the readme describes is correct. The zip has the extra folder. I have corrected this and reposted the zip.

10 Feb 2010, 2:09 PM
#289
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

gjh42:

What image names do you have, and where are they saved?
You do want a base image named (in this case) smartimg.jpg, for display when there is no specific image matching a page. If there is no match, the function will return null, and the base name and extension will be used.

Image names are like this
smartimg.jpg
smartimg_11.jpg
smartimg_shippinginfo.jpg
etc.

Images are saved in includes/templates/custom/images/

The function is returning null regardless of the page I am on, so the base image is the only one displayed. So the code is working, it's just that the function is returning null regardless.

I guessed that there shouldn't be an override, since the site locked every time I tried to use the function in the override folder.

10 Feb 2010, 5:12 PM
#290
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

This is a bit annoying. I threw the not-yet-tested 3.0 zip up in another thread with a request to let me know about any problems. 33 people downloaded it, but not one came back with a question.

Moving the code from tpl_main_page to a function broke it, as $current_page_base is not available inside a function without special arrangements. $_GET['main_page'] is available everywhere, so I have switched the function to use that, and it now works correctly. I have also improved the readme with a note about the base image for foreground image switching.

10 Feb 2010, 5:51 PM
#291
crunch avatar

crunch

Zen Follower

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

Re: Smart Backgrounds support

Is there a demo of this in action? I checked a few random sites in this thread and no one appears to be using it, site is still in dev or their site is no longer valid.

Thanks!

10 Feb 2010, 5:59 PM
#292
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

gjh42:

This is a bit annoying. I threw the not-yet-tested 3.0 zip up in another thread with a request to let me know about any problems. 33 people downloaded it, but not one came back with a question.

Moving the code from tpl_main_page to a function broke it, as $current_page_base is not available inside a function without special arrangements. $_GET['main_page'] is available everywhere, so I have switched the function to use that, and it now works correctly. I have also improved the readme with a note about the base image for foreground image switching.

Awesome Glenn!

Works like a charm. Thank you for the quick fix.

For the person asking about whether anyone is using this, I am.

I do not use the backgrounds portion or the css--just the foreground usage in the header logo image.

https://www.noquartercoffee.com

10 Feb 2010, 6:09 PM
#293
crunch avatar

crunch

Zen Follower

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

Re: Smart Backgrounds support

So your site is just using this contribution to change the main site header logo image? That's what I initially thought this contribution was for, but then I got a bit confused about the background functionality.

So, you can have the header logo image change for any Category and sub-category?

Thanks for the functioning link example.

10 Feb 2010, 6:46 PM
#294
cfsheridan avatar

cfsheridan

New Zenner

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

Re: Smart Backgrounds support

The nice part of using the background function is that you can have one little bit of code and modify the css to manage the images. The code allows for the placement of a class in the main page, which you can then use in the css to put specific background images in different places.

Since I am scaling a larger image for my logo (and need the hard boundaries of the <img> container, backgrounds doesn't work for my application.

10 Feb 2010, 7:18 PM
#295
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

The very first version of Smart Backgrounds was built for changing only the header background, and adaptable by recoding to other locations. It has since become universally applicable, but the original description always stays at the top of a mod's page in Free Addons. Look at the version descriptions for updates on functionality.

10 Feb 2010, 7:21 PM
#296
crunch avatar

crunch

Zen Follower

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

Re: Smart Backgrounds support

Question... Is this the only line of code that needs to be merged into a custom template version of 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.'"'; ?>>

Yes, I am using winmerge, but the template I am using has some line spacing and formatting issues that get flagged as changes and it's making it difficult to see actual code differences. Thanks.

10 Feb 2010, 8:04 PM
#297
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

That is correct. The only change from the stock file is the addition of the class to the body tag.```php
class="smartBG<?php echo smart_backgrounds();?>"

10 Feb 2010, 8:47 PM
#298
crunch avatar

crunch

Zen Follower

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

Re: Smart Backgrounds support

Wondering if I have missing something here...

My goal is to just have the header logo change on category entry...

Here is what I've done so far...

  1. I merged in the line of code from tpl_main_page.php into my custom template file version.

  2. I edited the stylesheet_smartbg.css to add the following (the number corresponds to my category ID):

.smartBG_1 #logo {background-image: url(../images/smartbg_1.gif);}
.smartBG_4 #logo {background-image: url(../images/smartbg_4.gif);}
.smartBG_45 #logo {background-image: url(../images/smartbg_45.gif);}
.smartBG_46 #logo {background-image: url(../images/smartbg_46.gif);}

  1. Verified package uploaded to correct folders

  2. Uploaded images to the template images directory.

The header logo image is not changing when entering a category. Did I miss editing another file?

10 Feb 2010, 9:01 PM
#299
gjh42 avatar

gjh42

Black Belt

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

Re: Smart Backgrounds support

Can you post a link to see your site?

Did you clear out the logo image by using pixel_trans.gif or the like? Changing the logo background will be invisible if the original foreground image is still there.

10 Feb 2010, 9:12 PM
#300
crunch avatar

crunch

Zen Follower

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

Re: Smart Backgrounds support

I guess I didn't understand the bit about using pixel_trans.gif.

OK. Went through the readme again. I just updated header.php with define('HEADER_LOGO_IMAGE', 'pixel_trans.gif');

But this destroys my normal logo header image. Think I am still missing something here.