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)
-   -   Customizing right side column (https://forum.x-cart.com/showthread.php?t=55020)

golfland 08-11-2010 08:54 AM

Customizing right side column
 
We are creating a lot of resources that are specific to certain categories. I have created a tpl containing links to these resources for several categories but I am not sure how to make the correct file show on the correct category.

For example, if I have a category called dogs, I want to show all our dog resource links on the right side. Same with birds, fish, etc. each will have its own resource link section that I only want to show when you are on the relevant category.

Code I have tried and diod not work:

<!-- right bar -->
{if $main neq "catalog" || $current_category.category eq "11"}
{include file="customer/main/dogs.tpl"}
{/if}
------

{if $main neq "catalog" && $current_category.category eq "11"}
{include file="customer/main/dogs.tpl"}
{/if}
------

{if $current_category.category eq "11"}
{include file="customer/main/dogs.tpl"}
{/if}
-----

{if $current_category eq "11"}
{include file="customer/main/dogs.tpl"}
{/if}
------
none of these seemed to do the trick. Anyone got any ideas on how to have a file show only for a select category?

Thanks!

Shamun 08-11-2010 10:47 AM

Re: Customizing right side column
 
You're looking for {$current_category.categoryid} if its for 4.3
May also want {$current_category.parentid} if it's a subcategory of dogs.

golfland 08-11-2010 12:00 PM

Re: Customizing right side column
 
Tal, Thank you for your reply. I still cannot seem to get this to work properly.

I have tried:
{if $current_category.parentid eq "11" || $current_category.categoryid eq "11"}
{include file="xxx/.tpl"}
{/if}

{if $current_category.parentid eq "11"}
{include file="xxx/.tpl"}
{/if}

{if $current_category.categoryid eq "11"}
{include file="xxx/.tpl"}
{/if}

Oddly when i tried
{if $current_category.categoryid neq "11"}
{include file="xxx/.tpl"}
{/if}
the tpl showed on a different category and only appeared on this 1 category? What this 1 category had that no other one had was featured product. Not sure if that is just coincidence or if featured products are affecting this some how?

Is there a x-cart smarty cheat sheet or some other x-cart smarty resource? How can I know what variables are available to try. current_category.categoryid seems logical.. not sure what else to try. The tpl did pull using 'neq' so I can safely assume the path and the the tpl file itself are not the issue.
Thanks!

Balinor/Moderator - should this be thread moved to program logic forum?

golfland 08-11-2010 12:22 PM

Re: Customizing right side column
 
I tried teh below and it did work with a different tpl file, so code is correct. thanks again Tal, just need figure the issue in the tpl I created.

{if $current_category.categoryid eq "11"}
{include file="xxx/.tpl"}
{/if}

thanks!

Shamun 08-11-2010 12:23 PM

Re: Customizing right side column
 
Go to admin settings and in the general options area at the very bottom is a checkmark to enable/disable debug mode. Turn that on and whenever you view a page you'll get a pop-up with all available variable names and arrays.

It's formated as {$varName.$arrayName} when you want to access them on a tpl.

So a var with the name of $foo had an array with a var inside with a name of bar then you would use {$foo.bar} in the tpl.



$current_category.categoryid = Only for the current category. Look at the url and you'll see the number for the category.
$current_category.parentid = Only for the parent category. Go up one level and you'll see it.

golfland 08-11-2010 12:37 PM

Re: Customizing right side column
 
Good stuff.. I got it all working perfectly now using:
{if $current_category.categoryid eq"11" || $current_category.parentid eq "11"}

fixed tpl, all is golden. thanks again


All times are GMT -8. The time now is 06:33 PM.

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