| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
ALWAYS display first level subcats beneath root cats | ||||
|
|
Thread Tools | Search this Thread |
#31
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Hey this is a really interesting thread for me. I have just begun to seriously edit and create new templates for an X-Cart Gold 4.15 store. The goal is to produce it with table-less xhtml/css and have it produce valid markup.
I've taken the latest code from dalmuti and simplified it slightly so that it outputs the categories and subcategories as an unordered list (I'll post it once it's done). I just have a couple of questions first. 1) I would like to highlight the category that is currently in view. I have a css class that I can use called "current" to do this; <li class="current">some-category</li>. I'm just not sure how to write the conditional statement. Is there a resource I can use to look this stuff up in. 2) I would also like to keep the sub-categories of a current category in view while browsing around that sub-category. Is the code that chris2002 posted the best/only way to do this. Thanks a lot. Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
#32
|
|||||||||
|
|||||||||
Re: ALWAYS display first level subcats beneath root cats
Solution for 4.1.6
like this CAT A --CAT A1 --CAT A2 CAT B --CAT B1 --CAT B2 in incude/categorie.php Search for this in your code : # # Override subcategory_count for Admin area # if(!empty($subcategories) && ($current_area == 'A' || ($current_area == 'P' && $active_modules['Simple_Mode']))) { $product_counts = func_query_hash("SELECT categoryid, COUNT(*) FROM $sql_tbl[products_categories] WHERE categoryid IN ('".implode("','", array_keys($subcategories))."') GROUP BY categoryid", "categoryid", false, true); foreach($subcategories as $k => $v) { $subcategories[$k]['subcategory_count'] = func_query_first_cell("SELECT COUNT(subcat.categoryid) as subc FROM $sql_tbl[categories] USE INDEX (PRIMARY) LEFT JOIN $sql_tbl[categories] as subcat ON subcat.categoryid_path LIKE CONCAT($sql_tbl[categories].categoryid_path, '/%') WHERE $sql_tbl[categories].categoryid = '$k' GROUP BY $sql_tbl[categories].categoryid"); $subcategories[$k]['product_count_global'] = $subcategories[$k]['product_count']; $subcategories[$k]['product_count'] = isset($product_counts[$k]) ? intval($product_counts[$k]) : 0; } } then add this just below the line : //Subcategories in menu function func_getallsubcat() { $raj =func_get_categories_list("", true, "all"); $raj1=$raj['all_categories']; $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 and in skin1/customer/categories.tpl Where you need to show the subcategorie {assign var=in value=$c.categoryid} {foreach from=$allsubcategories.$in item=c } and the link to show subcategories <a href="home.php?cat={$c.categoryid}" class="yourclassforsub">{$c.category}<br></a> thank you I was forogotten it in my previous post Thank you
__________________
Chris ---------------------------------------- X-Cart Gold 4.1.xx / 4.2.xx Need some Help in french Webdesign or else. ---------------------------------------- |
|||||||||
#33
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Thanks for the quick reply Chris.
Actually I wanted something like this. I'm looking at the products in --CAT A2 and want the menu to look like this: (I'd also like to highlight CAT A and --CAT A2) CAT A --CAT A1 --CAT A2 CAT B CAT C CAT D When I'm looking at one of the subs in CAT C, I'd like it to look like this: CAT A CAT B CAT C --CAT C1 --CAT C2 --CAT C3 CAT D Thanks, Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
#34
|
|||||||||
|
|||||||||
Re: ALWAYS display first level subcats beneath root cats
Ok I see,
I send you a solution to display all subcategorie, you just need to customize it in a CSS menu if you like than you can have what you want without a lot of modifications in the main source code. You can see a lot of exemple CSS menu at this URL. http://www.cssplay.co.uk/menus/index.html Hope that help you . Thanks
__________________
Chris ---------------------------------------- X-Cart Gold 4.1.xx / 4.2.xx Need some Help in french Webdesign or else. ---------------------------------------- |
|||||||||
#35
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Thanks Chris,
Scratch my previous comment I think you have included everything in your post, #32 I'll make some edits and hopefully have some code to post showing it with unordered lists. Thanks again, Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
#36
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Oh, so close but not yet perfect. I'm almost done.
BTW: Modifying the categories.tpl has been the most rewarding part of the project! Chris2002 and Dalmuti: My hats off to both of you! Once I'm finished, I'll post the mods I've done and include a the css I've used to produce the categories navigation. I'm still hung up on how I can detect which category and subcategory is in view. Example: How do I know that I am viewing --CAT A2? How do I know --CAT A2 is a sub-category of CAT A? CAT A --CAT A1 --CAT A2 CAT B --CAT B1 --CAT B2 Once I know how to do this, I can modify categories.tpl with conditions to only show the sub-categories of the parent in view or of the subcategories in view. I can also put in a condition to highlight the current category. Thanks for all the help. Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
#37
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Success!
Hopefully someone will benefit from the following (and previous) code and explanation. The following mods will provide a hierarchy (list) of navigation links where the current top level item will be highlighted in CSS and a listing of the sub-categories listed out. If a sub-item or sub-category is currently in view then that particular sub-category will also be highlighted in CSS. This works for 4.15 but I'm not sure how or if it will work with earlier versions. 1) First and foremost, you'll have to modify your categories.php file as per Chris2002's instructions. POST #32 2) Now you'll have to edit your categories.tpl to output the list of links along with some methods to highlight the links. I found the post that was put up by Dalmuti POST #28 really helpful. Then I had to do some research and mind numbing experimentation with the changes introduced by the categories.php mod until I got it figured out. My categories.tpl now looks like this: Code:
3) There is a CSS stylesheet that accompanies this mod and provides some indentation, fonts size and highlighting. I'm using heading tags <h3> & <h4> to provide some semantic sense to the categories and also it lets me indent them and adjust the text as much as I want through the stylesheet. Categories & Sub-cats are black Highlighted categories and sub-cats are bright green Rollovers are red It goes a little like this: Code:
I got a whole lot of help through searching and reading the previous posts about this and I hope this helps someone else too. Cheers, Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
|
#38
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
GREAT WORK AWASSON!!
I've been trying to get this result for a while now, worked great immediately, just needed to tweak for my site. THANKS FOR POSTING!!
__________________
x-cart 4.1.6 PHP 4.4.2 MySQL server 4.0.26-log MySQL client 5.0.20 Operation system FreeBSD Perl 5.008008 |
|||||||
#39
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Glad to help robf.
I can't take all the credit though. I just took some of the advice posted earlier and then tweaked it a little. I have to admit though, it sure works nicely Andrew
__________________
X-Cart Gold Version 4.15 PHP 5.16 / MySQL 5.022 Apache 2.2.3 / Linux (Fedora Core 6) |
|||||||
#40
|
|||||||
|
|||||||
Re: ALWAYS display first level subcats beneath root cats
Great mod. Save me a couple of hours. I modified the css code to work with FF, and Opera. The main thing I did was removing the bullets by adding code in the css list-style-type: none;. I am posting my modified css here.
Code:
__________________
Xcart 4.0.17 - XAOM - XRMA - Special Offer - Sales & Stats ______ www.futurevis.com |
|||||||
|
|||
X-Cart forums © 2001-2020
|