X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How do you vary the Header via Category? (https://forum.x-cart.com/showthread.php?t=48745)

Marc Washburn 07-22-2009 11:11 AM

How do you vary the Header via Category?
 
I have converted a static site of a customer and moved the product and categories to a X-Cart 4.2 Gold shopping cart system.

See here: http://www.shopdelicae.com/

Unfortunately they used to have unique header photos that changed depending on the category. For example a photo of steaks on the grill for the BBQ category, photo of Berries for the Jellies/Jam category etc.

Is there anyway to do this with X-cart 4.2?

I have all the artwork, but nowhere to put it

thanks,

Marc

pauldodman 07-22-2009 11:56 AM

Re: How do you vary the Header via Category?
 
One way to do this is to hard code the images in within an if statement.
{if $cat eq "1"} image1 {elseif $cat eq "2"} image2 {else} mainimage {/if}
getting the no from the category IDs.

ARW VISIONS 07-22-2009 11:57 AM

Re: How do you vary the Header via Category?
 
sure you can use smarty and set if conditions to show any image you like.

for example.

{if $cat=22}<img src="{$ImagesDir}/yourcategory22image.jpg" alt="" />
{elseif $cat=23}<img src="{$ImagesDir}/yourcategory23image.jpg" alt="" />
{elseif $cat=24}<img src="{$ImagesDir}/yourcategory23image.jpg" alt="" />
{else}defaultpic.jpg
{/if}

This would go in teh head.tpl wherever you want the image to apear.

upload the iamges to your skin1/images folder.

Shamun 07-22-2009 03:15 PM

Re: How do you vary the Header via Category?
 
Wouldn't it also be possible to do the following for flexibility?

{if $cat=1234}<div class="class">header</div>{/if}

carpeperdiem 07-22-2009 03:22 PM

Re: How do you vary the Header via Category?
 
Guys,

You are all working too hard!

Have you forgotten that you can put html into the category header?

/admin/category_modify.php?cat=x

Put your header image in the description field.

:-)

ARW VISIONS 07-22-2009 05:02 PM

Re: How do you vary the Header via Category?
 
he wants the iamge to change in the header, not the cat description.

cflsystems 07-22-2009 07:40 PM

Re: How do you vary the Header via Category?
 
There is "category icon" for each category. Upload your image there for each category and then just change the code for the header image to read
(code taken from subcategories.tpl)
Code:


<img class="subcategory-image" src="{$current_category.icon_url|amp}" alt="{$current_category.category|escape}"{if $current_category.image_x} width="{$current_category.image_x}"{/if}{if $current_category.image_y} height="{$current_category.image_y}"{/if} />

or this (code taken from subcategories_t.tpl)
Code:


<img src="{$subcategory.icon_url|amp}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" />

whichever works

Marc Washburn 07-24-2009 07:00 PM

Re: How do you vary the Header via Category?
 
Quote:

Originally Posted by Tal
Wouldn't it also be possible to do the following for flexibility?

{if $cat=1234}<div class="class">header</div>{/if}


Thank you everyone for the many possible answers to my question. Unfortunately my skills are very good with CSS & HTML, but very bad with JavaScript and Smarty Templates.

My design relies on CSS to create the graphic for the header, so from reading the replies, Tal's code snippet seems to be the closest solution to my design.

Here is some more information regarding my current header design.

As the bases for the website I used the Neon Lights template. I then modified the CSS for the header with the following:

"body {
background: transparent url(images/neon_lights/bg_left.gif) left top repeat-y;"

and

"#header {
height: 155px;
position: absolute;
top: 0;
left: 0;
width: 100%;
background: #ffffff url(images/neon_lights/head_bg.gif) repeat-x 1px top;
}"

So I have a base graphic which has the logo and a repeating graphic that tiles in order to allow for a photo that tiles (they are almost identical but the non-tiling graphic is locked into the top left to display the company logo).

So how, and in what module can I create some code snippet to swap out the CSS setting (via a class change) to swap out the two graphics for each category?

thanks for further assistance.

Marc

gb2world 07-24-2009 07:15 PM

Re: How do you vary the Header via Category?
 
You can define styles to overwite the skin1.css when you need to. You can have your default style is skin1.css, then for categories where you want to change it, add css to override it in home.tpl. You could add something like this before </head>:


Code:

<style type="text/css">
<!--
{if $current_category.categoryid eq 123}
 #header {background: #ffffff url(images/neon_lights/head_bg_123.gif) repeat-x 1px top;}
{/if}
{if $current_category.categoryid eq 456}
 #header {background: #ffffff url(images/neon_lights/head_bg_456.gif) repeat-x 1px top;}
{/if}

-->
 </style>


Marc Washburn 07-25-2009 07:06 AM

Re: How do you vary the Header via Category?
 
Ok,

Thanks GB2World, I tried your code snippet, but it fails with this error message:

The code I created and placed just before the </head> tag is:

Code:

<style type="text/css">
<!--
{if $current_category.categoryid eq 25}
 #body {background: transparent url(images/neon_lights/head_top2.gif) left top repeat-y;}
{/if}
-->
 </style>


the error I get when refreshing the page viewing any category is:

Error: Smarty error: [in customer/home.tpl line 20]: syntax error: unrecognized tag: background: transparent url(images/neon_lights/head_top2.gif) left top repeat-y; (Smarty_Compiler.class.php, line 446) in /home/delicae/wwwroot/shopdelicae.com/include/lib/smarty/Smarty.class.php on line 1092

after hitting the refresh button, the error goes away, but it doesn't swap out the image, so its not working.

Any ideas, your code snipped makes sense to me, but I guess not the PHP compiler?

gb2world 07-25-2009 09:13 AM

Re: How do you vary the Header via Category?
 
I think surrounding it with {literal} and {/literal} should keep smarty compiler from trying to figure out the brackets. So, this should compile without smarty errors:


Code:

<style type="text/css">
<!--
{if $current_category.categoryid eq 123}
 {literal}#header {background: #ffffff url(images/neon_lights/head_bg_123.gif) repeat-x 1px top;}{/literal}
{/if}
{if $current_category.categoryid eq 456}
 {literal}#header {background: #ffffff url(images/neon_lights/head_bg_456.gif) repeat-x 1px top;}{/literal}
{/if}

-->
 </style>


Marc Washburn 07-25-2009 11:25 AM

Re: How do you vary the Header via Category?
 
gb2world and everyone else...thank you SOOO MUCH!

Got it working via this code:

Code:

<style type="text/css">
{if $current_category.categoryid > 5 and $current_category.categoryid < 8}
<!--
 {literal}
        #header .head_wrap {background: transparent url(/skin1/images/neon_lights/head_top_coffee.jpg) left top no-repeat;}
        #header .line1 {background: transparent url(/skin1/images/neon_lights/head_top_coffee.jpg) left top no-repeat;}
        #header        {background: #ffffff url(/skin1/images/neon_lights/head_bg_coffee.jpg) repeat-x 1px top;}
 {/literal}
-->
{/if}
{if $current_category.categoryid eq 2 or $current_category.categoryid eq 3 or $current_category.categoryid eq 5 or $current_category.categoryid eq 32 or $current_category.categoryid eq 33}
<!--
 {literal}
        #header .head_wrap {background: transparent url(/skin1/images/neon_lights/head_top_bread.jpg) left top no-repeat;}
        #header .line1 {background: transparent url(/skin1/images/neon_lights/head_top_bread.jpg) left top no-repeat;}
        #header        {background: #ffffff url(/skin1/images/neon_lights/head_bg_bread.jpg) repeat-x 1px top;}
 {/literal}
-->
{/if}
</style>


Thank you again for everyone's help. I am proud of myself as this is the first time I am coding in Smarty. The last languages I coded in was Pascal and Cobol...

I had a couple of other formatting issues and errors, but using the Firefox Plug in 'Webmaster Tools', I was able to follow the CSS code and see when the variables worked and didn't work.

thanks again,

gb2world 07-25-2009 12:15 PM

Re: How do you vary the Header via Category?
 
Be sure and get firebug - it is indispensable for debugging css and html (& javascript).


All times are GMT -8. The time now is 04:46 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.