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)
-   -   Link to sub-category in menu (https://forum.x-cart.com/showthread.php?t=68164)

AKassing 11-15-2013 01:14 AM

Link to sub-category in menu
 
I've created language variables for all my categories, but I don't know how to add a link to a (sub-)categoryto another menu properly.
I used "<li><a href="home.php?cat=47">Horror</a></li>" and this works, but the names are static.
What do I need to change so the title of this link automaticaly displays the correct language variable?

Thanks,

Alexandra

carpeperdiem 11-15-2013 02:13 AM

Re: Link to sub-category in menu
 
Quote:

Originally Posted by AKassing
I've created language variables for all my categories, but I don't know how to add a link to a (sub-)categoryto another menu properly.
I used "<li><a href="home.php?cat=47">Horror</a></li>" and this works, but the names are static.
What do I need to change so the title of this link automaticaly displays the correct language variable?


Huh? There is no need to make language vars for categories or products.
Use Smarty vars to make your links... such as:

{$catid}

look at the code used in fancy categories for examples.
/skin/common_files/modules/Flyout_Menus/Icons/fancy_subcategories.tpl

Basically, let xcart (smarty) do the work.

vasilis 11-15-2013 02:22 AM

Re: Link to sub-category in menu
 
If you mean, displaying a category name in alternative site language in a different place in the page, you could try the following code (I am not sure if this is what you mean):

Code:

{foreach from=$categories_menu_list item=c name=categories}
{if $c.categoryid eq '47'}
<li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
{/if}
 {/foreach}


The variable names might differ, according to your xcart version.

AKassing 11-15-2013 02:34 AM

Re: Link to sub-category in menu
 
Quote:

Originally Posted by carpeperdiem
Huh? There is no need to make language vars for categories or products.
Use Smarty vars to make your links... such as:

{$catid}

look at the code used in fancy categories for examples.
/skin/common_files/modules/Flyout_Menus/Icons/fancy_subcategories.tpl

Basically, let xcart (smarty) do the work.


Thanks for the reply, but although I've checked fancy_subcategories.tpl, I still don't understand how to fix my problem.

AKassing 11-15-2013 02:40 AM

Re: Link to sub-category in menu
 
Quote:

Originally Posted by vasilis
If you mean, displaying a category name in alternative site language in a different place in the page, you could try the following code (I am not sure if this is what you mean):

Code:

{foreach from=$categories_menu_list item=c name=categories}
{if $c.categoryid eq '47'}
<li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
{/if}
 {/foreach}


The variable names might differ, according to your xcart version.


I just want the sub-categories from category "All Products" to be visible in another menu. I got this to work by adding this:
<li><a href="home.php?cat=47">Horror</a></li>
<li><a href="home.php?cat=50">Sci-Fi Science Fiction</a></li>
<li><a href="home.php?cat=6">Disney</a></li>
<li><a href="home.php?cat=40">Music & Dance</a></li>
<li><a href="home.php?cat=44">Western</a></li>
<li><a href="home.php?cat=48">War</a></li>
<li><a href="home.php?cat=42">Martial Arts</a></li>
<li><a href="home.php?cat=45">James Bond 007</a></li>
<li><a href="home.php?cat=41">Kids & Animation</a></li>
<li><a href="home.php?cat=43">(S)exploitation</a></li>
<li><a href="home.php?cat=46">Marvel & Superheroes</a></li>
<li><a href="home.php?cat=49">Vintage-Classic Pre-1970</a></li>

However, I want X-Cart to automaticaly display the corresponding title of that sub-category in the correct language. The way I did it they are the same in all languages. What code do I need to add or replace the above titles with?

vasilis 11-15-2013 02:53 AM

Re: Link to sub-category in menu
 
In your initial post, you had referred to one specific subcategory with id 47.
If you mean displaying all subcategories in a different place, you could just insert:
Quote:

{include file="customer/categories.tpl"}
in the template that renders this menu. That's the snippet by which x-cart displays categories.
If I missed something, let me know.

AKassing 11-15-2013 03:05 AM

Re: Link to sub-category in menu
 
Quote:

Originally Posted by vasilis
In your initial post, you had referred to one specific subcategory with id 47.
If you mean displaying all subcategories in a different place, you could just insert:

in the template that renders this menu. That's the snippet by which x-cart displays categories.
If I missed something, let me know.


The specific subcategory with id 47 was used as an example, because I want to be able to add links to specific subcategories.

When I try your code it adds a clone of the original categories menu. I just need links to all the sub-categories, minus the first one (All Our Products), from the main category "All Products".

AKassing 11-19-2013 04:58 AM

Re: Link to sub-category in menu
 
Okay I fixed this problem:
I used "<li><a href="home.php?cat=47">Horror</a></li>"

Changed this to:
<li><a href="home.php?cat=47">{$lng.lbl_genre_horror}</a></li>

Now you can set different titles for all languages and they can be different from the actual category name. Hope someone else can profit from this solution.


All times are GMT -8. The time now is 11:08 AM.

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