| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
if/else for a specific category in the <head> section? | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I am well aware of how to use the {if $cat eq "1"} do this {/if} from within a template -- if the template is in the body of the html.
I a STUMPED! however of how to use the {if $cat == "1"} to load a category specific style sheet or javascript. FOR EXAMPLE: in /skin1/customer/home.tpl just before the </head> I want to insert a stylesheet unique to category 19, and a link to a javascript file, only if a specific product or category is present. I tried this: Code:
Hmm... didnt work. I tried {if $cat == '19'} - and a bunch of variations. IS THE PROBLEM that the <head> loads before the <body> and until the body loads, there is no way to trap for the category? ![]() DO I HAVE TO load javascript and css links in the <head> - or can I put a css link in the body of a page? I have never done this... Experts??? Thanks, Jeremy UPDATE: It turns out the "category" I want to do this with is actually a sub-cat, if I use the if/else for the PARENT category, it works, but if I use {if $cat eq "z"} [and z=the number of the subcategory] then it fails to work. Hmm... I tried $subcat eq "z" -- no good. Any ideas how to do this with the subcat # ??? Thanks!
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() If it's for the current category, you should be able to use {if $current_category.categoryid eq "X"}Include{/if}.
Otherwise if you post specific category urls and ids I'll see if I can help you. |
|||||||||
#3
|
|||||||
|
|||||||
![]() Hi Jon,
Unfortunately, made no diff. Same results. {if $current_category.categoryid eq "9"} --(which is the "parent" category) -- works perfectly {if $current_category.categoryid eq "19"} --(which is the "child" subcategory) -- does not Hmm. The url is my domain.com/makeup/pretty-n-polished.html (this is category 19) Does CDSEO help or hinder such a category call in smarty? Come to think of it, I have a bit of code to redirect a single category to the product... http://forum.x-cart.com/showthread.php?t=23339 Maybe this is getting in the way?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() You're correct, the single product in a category redirect is causing your problem here.
http://www.mommymakeup.com/makeup/pretty-n-polished.html <- This is a product page. Use: {if $product.categoryid eq "X}Include{/if} or {if $product.productid eq "X}Include{/if} |
|||||||||
#5
|
|||||||
|
|||||||
![]() Jon,
{if $product.productid eq "X}Include{/if} worked great. thank you. I guess the "single product in a category" code kills the subcat relationship -- so I must use a direct product var. Now a question to anyone reading this far: Does having a bunch of these if/elses in home.tpl slow my site down? {if $product.productid eq "1" || $product.productid eq "11" || $product.productid eq "21"} How much overhead does smarty use when parsing a list of if/else(s) ? Should I be concerned? I see lists of if/elses in home_main.tpl and other templates... does this take a bite out of performance? Thanks! Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
|
|||
X-Cart forums © 2001-2020
|