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)
-   -   New section with popular categories (https://forum.x-cart.com/showthread.php?t=61564)

David-Allan 11-10-2011 07:55 AM

New section with popular categories
 
Hi Folks,

I need some help and I know how good most of you are at hacking to bits xcart.

We are looking to add a new section just above the categories on the left sidebar.

I have figured out that you can just include a tpl file and it will display it.

What i'm trying to do is add a section with our 5 most popular categories, these will be static and not dynamically generated.

Our site is www.robertsonpackaging.com

I tried editing the manufactures module but it doesnt show the same as a category would, ie its just shows a list of products.

I also tried just using html but not sure how to sort the css to look the same as the categories below which use fly out menus.

We need to have some existing categories listed above the existing categories list and then removed from the categories below. How would I go about this?

I have some limited php/html knowledge so can hack some bits together to get what i'm looking for but just can't seem to get my head round this smarty stuff just yet.

Any help with this would be greatly appreciated.

Thanks in advance

D-A

JWait 11-10-2011 08:53 AM

Re: New section with popular categories
 
Are you trying to include your "popular categories" within the "All Categories" box or separately? Do you want "flyout menus" or just a list?

Anyway, the easiest way is to make a "clone" of common_files/customer/categories.tpl naming it popular_categories.tpl.

Something like this...
Code:

{capture name=menu}
  {assign var="additional_class" value="menu-fancy-categories-list"
  <ul>
   
      <li{interline name=categories}><a href="LINK TO CATEGORY" title="CATEGORY NAME">CATEGORY NAME</a></li>

  </ul>

  {assign var="additional_class" value="menu-categories-list"}

{/capture}
{include file="customer/menu_dialog.tpl" title="Popular Categories" content=$smarty.capture.menu}
{/if}


Change the part that says "<li{interline name=categories}><a href="LINK TO CATEGORY" title="CATEGORY NAME">CATEGORY NAME</a></li>" to your link and title, and repeat for each category.

Then, in customer/left_bar.tpl for whatever skin you are using, look for
{include file="customer/categories.tpl"}

and just above it add
{include file="customer/popular_categories.tpl"}

EDIT: I made a mistake and forgot to exclude "flyout menus" in my original post (fixed now)

David-Allan 11-11-2011 02:17 AM

Re: New section with popular categories
 
Quote:

Originally Posted by JWait
Are you trying to include your "popular categories" within the "All Categories" box or separately?

separately in a little box above the category box.
Quote:

Originally Posted by JWait
Do you want "flyout menus" or just a list?

Flyout menu's would really be the best looking option but if that is too difficult then just static categories would be fine.
Quote:

Originally Posted by JWait
Anyway, the easiest way is to make a "clone" of common_files/customer/categories.tpl naming it popular_categories.tpl.

Something like this...
Code:

{capture name=menu}
  {assign var="additional_class" value="menu-fancy-categories-list"
  <ul>
   
      <li{interline name=categories}><a href="LINK TO CATEGORY" title="CATEGORY NAME">CATEGORY NAME</a></li>

  </ul>

  {assign var="additional_class" value="menu-categories-list"}

{/capture}
{include file="customer/menu_dialog.tpl" title="Popular Categories" content=$smarty.capture.menu}
{/if}


Change the part that says "<li{interline name=categories}><a href="LINK TO CATEGORY" title="CATEGORY NAME">CATEGORY NAME</a></li>" to your link and title, and repeat for each category.

Then, in customer/left_bar.tpl for whatever skin you are using, look for
{include file="customer/categories.tpl"}

and just above it add
{include file="customer/popular_categories.tpl"}

EDIT: I made a mistake and forgot to exclude "flyout menus" in my original post (fixed now)



Ahh ok thanks mate, so basically I use:
Code:

<li{interline name=categories}><a href="LINK TO CATEGORY" title="CATEGORY NAME">CATEGORY NAME</a></li>
for each category I want to list in between the list tags?

I'll give this a wee bash now on my dev site and see if I can get it to work.

Thank you so much for your help and speedy reply, I really appreciate it.

David-Allan 11-11-2011 03:11 AM

Re: New section with popular categories
 
JWAIT,

Thank you so much for your help I managed to get it to work using the following code

Code:

{capture name=menu}

  <ul>
      <li{interline name=categories}><a href="http://www.robertsonpackaging.com.previewdns.com/Bakery/}" title="Bakery Supplies">Bakery Supplies</a></li>
  </ul>

  {assign var="additional_class" value="menu-categories-list"}


{/capture}
{include file="customer/menu_dialog.tpl" title="Popular Categories" content=$smarty.capture.menu}


I don't know how difficult it would be to use this with the flyout module as it looks different from the other categories but it works for now which is great.

Do you know if there is a way of hiding categories in the main category list so they don't show up in the section below? like an exclude option or something like that?

I really appreciate your help with this mate, you make it look so easy :)

Thanks

D-A

JWait 11-11-2011 05:02 AM

Re: New section with popular categories
 
You might try something like this in common_files/customer/categories.tpl...
Code:

    {foreach from=$categories_menu_list item=c name=categories}
    {if $categories[cat_num].categoryid neq XXX}
      <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
    {/if}
    {/foreach}

You should be able to get the cat_num and cat id from the "Categories" section in admin.

There are 3rd party mods that will hide categories.

Check this thread for a possible solution....
http://forum.x-cart.com/showthread.php?t=44414

You might check this thread for a different solution...
http://forum.x-cart.com/showthread.php?t=52493&page=2

David-Allan 11-11-2011 06:27 AM

Re: New section with popular categories
 
Quote:

Originally Posted by JWait
You might try something like this in common_files/customer/categories.tpl...
Code:

    {foreach from=$categories_menu_list item=c name=categories}
    {if $categories[cat_num].categoryid neq XXX}
      <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
    {/if}
    {/foreach}

You should be able to get the cat_num and cat id from the "Categories" section in admin.

There are 3rd party mods that will hide categories.

Check this thread for a possible solution....
http://forum.x-cart.com/showthread.php?t=44414

You might check this thread for a different solution...
http://forum.x-cart.com/showthread.php?t=52493&page=2


Thanks mate getting closer to what I need with your help :)

I have just turned off flyout categories as it seems too complicated to try and get this working with those. I had a look at the code and it looks very complicated.

This is the code I have used but it doesn't seem to work. It actually doesn't seem to do anything. I dont know if I have missed something.

I have it on my live site at the moment. www.robertsonpackaging.com

Here is the code I used

Code:


<ul>
    {foreach from=$categories_menu_list item=c name=categories}
        {if $categories[cat_num].categoryid neq 199 || $categories[cat_num].categoryid neq 74 || $categories[cat_num].categoryid neq 246 || $categories[cat_num].categoryid neq 43}
      <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
      {/if}}
    {/foreach}

</ul>


:w

JWait 11-11-2011 07:21 AM

Re: New section with popular categories
 
Try changing "neq" to "ne" (I', not sure about that part being correct, its from someone else).

David-Allan 11-14-2011 08:39 AM

Re: New section with popular categories
 
JWait I just wanted to thank you for your help.

I have managed to get it all working now. I have even managed to remove the categories from the all categories list using an if statement that checks the the category position and if it's set to 666 it doesn't display it.

Your help is greatly appreciated.

D-A

David-Allan 11-16-2011 03:26 AM

Re: New section with popular categories
 
Quote:

Originally Posted by David-Allan
JWait I just wanted to thank you for your help.

I have managed to get it all working now. I have even managed to remove the categories from the all categories list using an if statement that checks the the category position and if it's set to 666 it doesn't display it.

Your help is greatly appreciated.

D-A


I'm an ejit, it doesn't actually work at all :) I just thought it did but hadn't noticed it had just moved the categories to the bottom of the categories list.

I guess I'll need to play about with that bit of code and see if I can get it to work.

David-Allan 11-16-2011 03:36 AM

Re: New section with popular categories
 
Quote:

Originally Posted by David-Allan
I'm an ejit, it doesn't actually work at all :) I just thought it did but hadn't noticed it had just moved the categories to the bottom of the categories list.

I guess I'll need to play about with that bit of code and see if I can get it to work.



I managed to get it working. I just replaced the code


Code:

{if $categories[cat_num].categoryid neq XXX}

With this

Code:

{if $c.order_by neq "XXX"}

That wasn't so bad as I thought.


All times are GMT -8. The time now is 07:21 AM.

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