Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Drop down/flyout categories... where do I start?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 12-04-2003, 07:15 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
"funkydunk"]Actually...here's the code for include/categories.php:

Hi Funkydunk,

I'm trying to display all categories as a tree.
How do you process subcategories in the loop?
Here is my "categories.tpl"

Code:
{section name=cat_num loop=$categories} <div id='menuLabel{%cat_num.index%}' class='menuLabel'>{ $categories[cat_num].category_name|escape }</div> <div id='menu{%cat_num.index%}' class='menuBox'> {section name=subcat_num loop=$subcategories} { $subcategories[subcat_num].category_name } {/section} </div> {/section}

loop=$subcategories is not correct. Is it possible to loop only subcategories for this category here with mod to categories.php you posted?[/quote]
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #12  
Old 12-04-2003, 07:44 PM
  leon's Avatar 
leon leon is offline
 

X-Wizard
  
Join Date: Mar 2003
Location: Costa Rica
Posts: 1,213
 

Default

Wonder if Funkydunk finished this cat mod ?
__________________
It doesn\'t matter what is done... it is how it is done.
=============================
XCart Version: 3.5.3 -> Dmcigars.com
XCart Version: 4.1.3....
Reply With Quote
  #13  
Old 12-04-2003, 11:06 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

I have it running on a couple of 3.4.x sites in different guises, but have given up on putting a full blown mod together due to the fancy categories mod of xcart 3.5.0.

The drop down cats are being used on:
kidsgloriouskids.co.uk
cable-shop.co.uk

The are both live sites so please no dummy orders.
__________________
ex x-cart guru
Reply With Quote
  #14  
Old 12-05-2003, 06:40 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
Originally Posted by funkydunk
I have it running on a couple of 3.4.x sites in different guises, but have given up on putting a full blown mod together due to the fancy categories mod of xcart 3.5.0.

Where can I get this fancy categories mod of xcart 3.5.0?
X-cart guys say they do not have it.

Any help with categories.tpl ? I need exactly what you've done.
Maybe I can buy it from you. Please let me know.
anton@27stars.com
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #15  
Old 12-05-2003, 07:38 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

ok cos i am in a good mood today...

include/categories.php

Code:
<? /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: categories.php,v 1.46.2.1 2003/06/02 11:57:44 svowl Exp $ # # # For users some categories may be disabled # if ($current_area == "C") { $membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') "; } else { $membership_condition = ""; } // funkydunk modification // amended query to get the main cat and subcat for each record $categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 2) as subcat from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category")); # # Put all categories into $all_categories array and find current_category # by categoryid stored in $cat # if(!$categories_data) $categories_data = array(); foreach($categories_data as $k=>$category_data) { if ($current_area == "C") { $int_res = func_query_first("SELECT * FROM $sql_tbl[categories_lng] WHERE code='$store_language' AND categoryid='$category_data[categoryid]'"); if ($int_res["category"]) $categories_data[$k]["category_name"] = $category_data["category_name"] = $int_res["category"]; if ($int_res["description"]) $categories_data[$k]["description"] = $category_data["description"] = $int_res["description"]; } if ($category_data["categoryid"]==$cat) { $current_category = $category_data; } // funkydunk code if(strstr($category_data["category"],"/")) { if ($category_data["category"] == $category_data["subcat"]){ // echo "got one"; // after taking off the initial category name this checks to see if this is only a sub category with no categories below it. // if i didn't do this the subcategory would be duplicated in the list $categories_data[$k]["subcatonly"]="true"; } } // end of funkydunk amended code $all_categories = $categories_data; // func_print_r ($all_categories); } # # Put all root categories to $categories array # Put all subcategories of current_category to $categories array # foreach($all_categories as $all_category) { $category=$all_category["category"]; $cur_dir_len = strlen($current_category["category"]); if(!strstr($category,"/")) { $categories[]=$all_category; if(empty($current_category)) { $subcategories[]=$all_category; } } if(substr($category,0,$cur_dir_len+1) == $current_category["category"]."/" and $category!=$current_category["category"]) if(!strstr(substr($category,$cur_dir_len+1),"/")) { $all_category["category"]=ereg_replace("^.*/","",$all_category["category"]); $subcategories[]=$all_category; } } # # Put subcategory_count to $subcategories array # if ($subcategories) foreach($subcategories as $key =>$subcategory) { $subcategory["subcategory_count"]=0; foreach($all_categories as $all_category) { if ($all_category["categoryid"]==$subcategory["categoryid"]) { $cur_dir_len = strlen($all_category["category"]); $current_subcategory=$all_category["category"]; } } foreach($all_categories as $all_category) { $category=$all_category["category"]; if(substr($category,0,$cur_dir_len+1) == $current_subcategory."/" and $category!=$current_subcategory) if(!strstr(substr($category,$cur_dir_len+1),"/")) $subcategory["subcategory_count"]++; } $subcategories[$key]["subcategory_count"]=$subcategory["subcategory_count"]; } # # Generate category sequence, i.e. # Books, Books/Poetry, Books/Poetry/Philosophy ... # $current_category_array = explode("/",$current_category["category"]); $prev = $current_category_array[0]; list($key,$val)=each($current_category_array); $new_array = array($val); while(list($key,$val)=each($current_category_array)) { $new_array[] = $prev."/".$val; $prev = $prev."/".$val; } unset($current_category_array); # # Generate array for displaying categories sequence in location # $category_location=array(); reset($all_categories); $my_cats = array (); foreach($all_categories as $all_category) { $categoryid=$all_category["categoryid"]; $category=$all_category["category"]; $my_cats [$categoryid] = $category; } asort ($my_cats); foreach ($my_cats as $categoryid => $category) { reset ($new_array); while(list($key,$val)=each($new_array)) { if ($val==$category) { foreach($categories_data as $category_data) { if ($category_data["categoryid"] == $categoryid) $val = $category_data["category_name"]; } $category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid); } } } # # Assign Smarty variables # $smarty->assign("allcategories",$all_categories); $smarty->assign("categories",$categories); $smarty->assign("subcategories",$subcategories); $smarty->assign("current_category",$current_category); $smarty->assign("cat",$cat); ?>

skin1/customer/categories.tpl

Code:
{* $Id: categories.tpl, modified by funkydunk 2003*} {capture name=menu} <div id="popmenu" class="menuskin" onMouseover="clearhidemenu();highlightmenu(event,'on')" onMouseout="highlightmenu(event,'off');dynamichide(event)"> </div> {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} {assign var="tmp" value="0"} {section name=cat loop=$allcategories} {if $allcategories[cat].maincat eq $categories[cat_num].category_name} {if $allcategories[cat].subcatonly}{assign var="tmp" value="1"}{/if} {/if} {/section} <font class=CategoriesList> <a href="home.php?cat={ $categories[cat_num].categoryid }" class="VertMenuItems" {if $tmp eq 1}onMouseover="showmenu(event,linkset[{$smarty.section.cat_num.index}])" onMouseout="delayhidemenu()"{/if}> { $categories[cat_num].category_name|escape }</a></font> {/section} {else} {section name=cat_num loop=$subcategories} <font class=CategoriesList>{ $subcategories[cat_num].category_name|escape }</font> {/section} {/if} {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu }

new template
customer/dropdown.tpl
Code:
{* dropdown.tpl funkydunk 2003 *} {literal} <script language="JavaScript1.2"> //Pop-it menu- By Dynamic Drive //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com //This credit MUST stay intact for use var linkset=new Array() //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT {/literal} {section name=cat_num loop=$categories} {assign var="temp" value="0"} {section name=cat loop=$allcategories} {if $allcategories[cat].maincat eq $categories[cat_num].category_name} {if $allcategories[cat].subcatonly} {$temp} {if $temp gt 0} linkset[{$smarty.section.cat_num.index}] +='<div class="menuitems">{$allcategories[cat].category_name}</div>' {else} linkset[{$smarty.section.cat_num.index}] ='<div class="menuitems">{$allcategories[cat].category_name}</div>' {/if} {math equation="temp+1" temp=$temp assign=temp} {/if} {/if} {/section} {/section} {literal} ////No need to edit beyond here var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1 var ns6=document.getElementById&&!document.all var ns4=document.layers function showmenu(e,which){ if (!document.all&&!document.getElementById&&!document.layers) return clearhidemenu() menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : "" menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj if (ie4||ns6) menuobj.innerHTML=which else{ menuobj.document.write('<layer name=gui bgColor=#081589 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>') menuobj.document.close() } menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height eventX=ie4? event.clientX : ns6? e.clientX : e.x eventY=ie4? event.clientY : ns6? e.clientY : e.y //Find out how close the mouse is to the corner of the window var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.contentwidth) //move the horizontal position of the menu to the left by it's width menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth else //position the horizontal position of the menu where the mouse was clicked // menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX //same concept with the vertical position if (bottomedge<menuobj.contentheight) menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? window.pageYOffset+eventY-menuobj.contentheight : eventY-menuobj.contentheight else menuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY menuobj.thestyle.visibility="visible" return false } function contains_ns6(a, b) { //Determines if 1 element in contained in another- by Brainjar.com while (b.parentNode) if ((b = b.parentNode) == a) return true; return false; } function hidemenu(){ if (window.menuobj) menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide" } function dynamichide(e){ if (ie4&&!menuobj.contains(e.toElement)) hidemenu() else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) hidemenu() } function delayhidemenu(){ if (ie4||ns6||ns4) delayhide=setTimeout("hidemenu()",500) } function clearhidemenu(){ if (window.delayhide) clearTimeout(delayhide) } function highlightmenu(e,state){ if (document.all) source_el=event.srcElement else if (document.getElementById) source_el=e.target if (source_el.className=="menuitems"){ source_el.id=(state=="on")? "mouseoverstyle" : "" } else{ while(source_el.id!="popmenu"){ source_el=document.getElementById? source_el.parentNode : source_el.parentElement if (source_el.className=="menuitems"){ source_el.id=(state=="on")? "mouseoverstyle" : "" } } } } if (ie4||ns6) document.onclick=hidemenu </script> {/literal}

lastly put an

{include file="customer/dropdown.tpl"} into the h<head> part of customer/home.tpl

SHould work nicely for you on version 3.4.x sites
__________________
ex x-cart guru
Reply With Quote
  #16  
Old 12-05-2003, 08:05 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
Originally Posted by funkydunk
ok cos i am in a good mood today...

Man,

I think you just saved my sanity. This is the first good news for today and it's already noon.

Thank you,
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #17  
Old 12-05-2003, 11:18 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

First of all, let me say you are the coolest and the greatest.
Works fine in 3.5.1
From all followers of the master : thank you

Second, for anybody who is trying to implement this mod of the week,
you will have to add this code to skin1.css

Code:
.menuskin{ position:absolute; width:165px; background-color:#EEEEEE; border:1px solid #003366; line-height:18px; z-index:100; visibility:hidden; font-size: 11px; left: 150px; } .menuskin a{ text-decoration:none; color:black; padding-left:10px; padding-right:10px; }

Thanks again!
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #18  
Old 12-05-2003, 03:03 PM
 
censat censat is offline
 

Advanced Member
  
Join Date: Dec 2002
Location: Morton,MS
Posts: 64
 

Default Re Mod

I put everything into place as described on this thread,but I get a this page error

Line 10266
Char 1
Error Object Expected
Code 0
Url http://www.centralsatellite.com/store/customer/home.php


What am I doing wrong?

Thank's
Censat
__________________
3.4.2 LIVE.....Modified a little....
Even Paranoids Can Have Real Enemies
Reply With Quote
  #19  
Old 12-05-2003, 04:04 PM
 
laureon laureon is offline
 

Senior Member
  
Join Date: Oct 2003
Posts: 171
 

Default

nice bit of code there! Successfully implemented in 3.5.1. Does this script only read 'Cat1' > 'Cat2' from the database? If so,is there a work around to read further categories e.g. 'Cat 1' > 'Cat 2' > 'Cat 3'?

thanks
Reply With Quote
  #20  
Old 12-05-2003, 07:56 PM
  leon's Avatar 
leon leon is offline
 

X-Wizard
  
Join Date: Mar 2003
Location: Costa Rica
Posts: 1,213
 

Default

Glad you are in a good mood, thanx, I will give it a try.
__________________
It doesn\'t matter what is done... it is how it is done.
=============================
XCart Version: 3.5.3 -> Dmcigars.com
XCart Version: 4.1.3....
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020