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 I display all subcategories along with all products (https://forum.x-cart.com/showthread.php?t=19730)

mikalou 10-26-2007 10:37 AM

Re: How do I display all subcategories along with all products
 
That store that I linked to is 4.1.8 and I used the instructions that were listed in a post above mine with the one modification that I mentioned in one of my other posts.

designtheweb 10-26-2007 03:29 PM

Re: How do I display all subcategories along with all products
 
I have tried this one and it works well except for one thing, it is only showing up the products of the last category not in other categories with products on the same level.

Any ideas?

Thanks.

MoonDog 10-27-2007 05:27 PM

Re: Display SubCategory titles with products
 
I just created something similar to what you need from an old posting a couple of days ago.
I just modified it a little to make it work on v4.1.8

First of all, kudos to the creator and all those that contributed to the original mod.

Start by opening up the xcart/include/categories.php file.
And find these lines of code: (it's at the bottom)
Code:


if (!empty($subcategories))
$smarty->assign("subcategories", $subcategories);
$smarty->assign("cat", $cat);
?>

And right above those lines of code add:
Code:


//Subcategories in menu
function sort_by_order_by($a, $b)
{
    if ($a['order_by'] == $b['order_by']) {
      return 0;
  }
  return ($a['order_by'] < $b['order_by']) ? -1 : 1;
}
function func_getallsubcat()
{
$raj =func_get_categories_list("", true, "all");
$raj1=$raj['all_categories'];
usort($raj1 ,"sort_by_order_by");
$ll=array();
foreach ($raj1 as $k=>$val)
{
if($val['parentid']!="0")
{
$ll[$val['parentid']][]=$val;
}
}
return $ll;
}
$smarty->assign("allsubcategories", func_getallsubcat());
//Subcategorie in menu - end


Now, replace your skin1/customer/categories.tpl with this modified categories.tpl

Code:


{* $Id: categories.tpl,v 1.26 2005/11/17 06:55:37 max Exp $ *}
{* modified *}
<div id="sidenavcontainer">
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{include file="modules/Fancy_Categories/categories.tpl"}
{assign var="fc_cellpadding" value="0"}
{else}
{if $config.General.root_categories eq "Y"}
<ul id="mainmenu">
{foreach from=$categories item=c}
{if $cat eq $c.categoryid || $current_category.parentid eq $c.categoryid}
<li><h3><a class="current" href="home.php?cat={$c.categoryid}">{$c.category}</a></h3></li>
{else}
<li><h3><a href="home.php?cat={$c.categoryid}">{$c.category}</a></h3></li>
{/if}
{assign var=in value=$c.categoryid}
{* CONDITIONAL DROP DOWN ITEMS FROM TOP CATEGORY *}
<ul id="submenu">
{foreach from=$allsubcategories.$in item=c }
{if $cat eq $c.categoryid}
<li><h4><a class="current" href="home.php?cat={$c.categoryid}">{$c.category}</a></h4></li>
{else}
<li><h4><a href="home.php?cat={$c.categoryid}">{$c.category}</a></h4></li>
{/if}
{/foreach}
</ul>
{* /CONDITIONAL *}
{/foreach}
{else}
{foreach from=$subcategories item=c key=catid}
<li><a href="home.php?cat={$catid}">{$c.category}</a></li>
{/foreach}
{/if}
</ul>
{/if}
</div>
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu cellpadding=$fc_cellpadding}

And the last thing you need to do is copy the following code and add it to the bottom of your skin1.css file
Code:


/**
* sidenavcontainer is 181px wide and a minimum of 400px high
* It has a little padding top and bottom as well
* Modify it to suit your layout
*/
html, body, ul, ol, li, p,
h1, h2, h3, h4, h5, h6,
form, fieldset, a {
    list-style-type: none;
    margin: 0;
    padding: 0;
    border: 0;
}
/*#sidenavcontainer {
    padding:200px 0 10px 0;
    PADDING-LEFT: 20px;
    PADDING-BOTTOM: 10px;
    width:181px;
    min-height:0px;
    float:left;
}
*/
h3{    /* PRODUCT CATEGORIES */
    padding:200;
    margin:100;
    font-size:11px;
    font-style:normal;
    font-weight:normal;
}
#sidenavcontainer h3 {
    margin:0 0 0 0px;
    padding:0px;
}
h4{    /* PRODUCT SUB-CATEGORIES */
    padding:0;
    margin:0;
    font-size:11px;
    font-style:normal;
    font-weight:normal;
}
#sidenavcontainer h4 {
    margin:0 0 0 20px;
    padding:20;
    padding-bottom:2px;
}
#sidenavcontainer a {
    color:#000000;
    text-decoration:none;
}
#sidenavcontainer a:hover {
    color:#FF0000;
    text-decoration:none;
}
#sidenavcontainer .current {
    color:#3333FF;
}


And that's it.

- MoonDog -

RobinBraves 10-28-2007 07:15 AM

Re: Display SubCategory titles with products
 
I followed the steps you gave, MoonDog, and I don't see a change: http://sentimentalist.net/store/greeting-cards-c-1.html

I even ran cleanup.php to make sure my temp files were cleaned out.

Did I do something wrong?

andyweb 10-28-2007 10:53 AM

Re: Display SubCategory titles with products
 
Hi MoonDog,

Thanks so much for this post.
I am also having the same problem.

I followed all the instructions, but still cant get the products to display in the menu.
It now displays the subcategories.

MoonDog 10-28-2007 12:31 PM

Re: Display SubCategory titles with products
 
1 Attachment(s)
RobinBraves,

Unfortunately you won't be able to use this code on your site :( . I went to your site (great site by the way) and noticed that you are using javascript code for your current menu. Since you have a customized menu you will have to remove and modify your code in order for this to work. By the way, on your site, the last three items of your custom menu doesn't work in Internet Explorer 6. You can't see any of the text unless you hover over them. It works OK in Firefox though.

andyweb,

I've copied the code from this post and followed my exact instructions to see if there was a typo or bad code. I re-installed it and tested it and it still works like a charm. I've attached a thumbnail so you can see what it is suppose to look like.
You might try re-doing the installation again in case you made a previous mistake.

- MoonDog -

RobinBraves 10-28-2007 02:16 PM

Re: Display SubCategory titles with products
 
Not sure if this is what I will need. Does this make the actual page in the middle show the subcategory titles with all their products listed below?

Example:
-------------------------------------------------------
Celebration
-------------------------------------------------------
product1 product2 product3

product4 product5

------------------------------------------------------
Gratitude
------------------------------------------------------
product1 product2 product3

------------------------------------------------------
Seasonal
------------------------------------------------------
product1 product2 product3

product4 product5 product6

product7

MoonDog 10-28-2007 03:37 PM

Re: Display SubCategory titles with products
 
RobinRaves,

Quote:


Does this make the actual page in the middle show the subcategory titles with all their products listed below?


My mistake:oops: . I thought you needed a categories menu with the listed sub-categories on the left side of the page.

I did post some code a while back that deals with sub-categories and sub-sub-categories in the middle of the page, but it used graphics and text. I'm not sure if this is what you need, but click here to go there. I've placed two thumbnail images on the bottom of that post so you can see if that is what you need.

- MoonDog -

RobinBraves 10-28-2007 08:19 PM

Re: Display SubCategory titles with products
 
No problem, MoonDog. I really do appreciate your help. I took a look at that other forum and it is not what I need.

What I need is seen here:
http://www.jackmansfabrics.com/Bridal-Fabrics-p-1-c-294.html

This page shows a SubCategory Heading with the products below and then ANOTHER SubCategory Heading below that and its products below and so forth.

By default, x-cart just shows the subcategories (with or without images) but not the products. You actually have to click on the subcategory to see the products of just that subcategory.

I need for my customer to see all the subcategory headings with the corresponding products below each.

I hope that makes sense. I saw 1 thread about this, but it was not made for 4.1.8 or newer.

I'm kinda bummed out. Good news is... I think I am going to use this mod anyway because the menu I have is "jumpy" and I'm not a huge fan.

RobinBraves 10-29-2007 09:08 PM

Re: How do I display all subcategories along with all products
 
Quote:

Originally Posted by mikalou
That store that I linked to is 4.1.8 and I used the instructions that were listed in a post above mine with the one modification that I mentioned in one of my other posts.


Okay, I followed the instructions exactly and also made the update that you posted. Here is what my page looks like:

http://sentimentalist.net/store/greeting-cards-c-1.html

Any suggestions? What could I be doing wrong/


All times are GMT -8. The time now is 01:26 PM.

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