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

Find current subcategories siblings?

 
Reply
   X-Cart forums > X-Cart 4 > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-11-2013, 08:46 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Question Find current subcategories siblings?

Can someone point me in the right direction as to how to determine what the current subcategory's parent category is, so I can then get all the parent's subcategories?

Thanks!~
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #2  
Old 11-11-2013, 09:05 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Find current subcategories siblings?

Look at the {$current_category} array. {$current_category.parentid} should contain the parent categoryid.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
qualiteam (11-11-2013)
  #3  
Old 11-11-2013, 09:07 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default Re: Find current subcategories siblings?

Thank you so much!

I was just coming back to post that I was able to locate the data I needed!
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #4  
Old 11-13-2013, 11:46 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default Re: Find current subcategories siblings?

Ummm.. ok. So I haven't been able to figure out how or if the subcategory siblings data exists already.. somewhere. I want to provide a select menu which contains all the sibling subcategories, but on the subcategory pages.. I am able to locate the data if I am on the parent category page.

Am I going to need to make my own function to get this data?

If so, is there a tutorial or thread that explains the hierarchy (not sure this is the right word)?

From looking through the php files, I see the functions are in the /include/func files (duh) and I understand the root level php files passes values into Smarty, which is then used in the .tpl files... is it alright to call a function from the root php files or do I need another level in there?
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #5  
Old 02-14-2015, 06:54 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Question Re: Find current subcategories siblings?

I have made a little progress on this. But I am still not getting the data I need

I am not just familiar with how xCart works and how to store/access data.

Any help would be greatly appreciated.

And a very special thank you to cherie, for getting me this far. I did not want to keep bothering cherie, which is why I am posting in this thread.

To recap, I need to build an array, something like this where parentid:

PHP Code:
$subCats = array ( 
                  
"parentid"  => array (  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name" 
                                       
), 
                  
"parentid"  => array (  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name" 
                                       
), 
                  
"parentid"  => array (  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name" 
                                       
), 
                  
"parentid"  => array (  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name",  
                                       
"subid" => "Category Name" 
                                       

                  ); 

The I need to retrieve and loop the array data based on $current_category.parentid.


What I current have, returns all the category names of all the subcategories but I can't figure out how to build the array correctly.


include/common.php
PHP Code:
$catResults "SELECT categoryid,category,parentid FROM $sql_tbl[categories] WHERE parentid!='0' AND avail='Y'";
$subCats func_query_hash($catResults,'parentid',false,true); 
$smarty->assign('subCats',$subCats); 

skin/<theme>/customer/main/subcategories.tpl
Code:
{foreach from=$subCats key=pid item=i} {$pid}: {$i.category} {/foreach}
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #6  
Old 02-17-2015, 06:37 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,734
 

Default Re: Find current subcategories siblings?

Why reinventing the wheel. If you are using the Flyout Menus module the categories array is already created. Just reuse it. I think it is called $categories_menu and subcategories for each category are under childs
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 02-17-2015, 03:01 PM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default Re: Find current subcategories siblings?

And if I am not, can I still tap into those functions?
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #8  
Old 02-17-2015, 04:20 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Find current subcategories siblings?

Quote:
Originally Posted by ScrapOrchard
And if I am not, can I still tap into those functions?
Certainly. I can understand why you might want your own control over this info.

Have you seen this webinar from Tony? http://kb.x-cart.com/pages/viewpage.action?pageId=7504837#Webinar2-10Apr2014-DesignchangesinX-Cart5(Custom...thmyownme nu?

It should get you familiar with overriding things.


Take a look at the attached file, it is my drop down menu module, rename the zip file to a tar, I just renamed it zip so I could upload.
Attached Files
File Type: zip Baby-DropDown-v5_1_0_3-levels.zip (79.5 KB, 13 views)
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
ScrapOrchard (03-02-2015)
  #9  
Old 02-17-2015, 04:52 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,734
 

Default Re: Find current subcategories siblings?

I believe this is for XC4 so the XC5 code won't work

If you are not using the Flyout Menus module you can still use its functions but you need to make your own calls to them to built the menu array
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
totaltec (02-18-2015)
  #10  
Old 02-17-2015, 05:18 PM
  PhilJ's Avatar 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Location: UK
Posts: 3,666
 

Default Re: Find current subcategories siblings?

(1) Uncheck General Settings > Appearance > "Always show root categories in the category list"

(2) Use...

Code:
<select onchange="window.location.href=this.value"> <option>{$lng.lbl_categories}...</option> {foreach from=$categories_menu_list item=c name=categories} <option value="home.php?cat={$c.categoryid}">{$c.category}</option> {/foreach} </select>

---
(1) May affect your main category menu though... It looks like yours is a custom menu, so you might get away with it.
Reply With Quote

The following user thanks PhilJ for this useful post:
totaltec (02-18-2015)
Reply
   X-Cart forums > X-Cart 4 > Changing design


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 05:37 PM.

   

 
X-Cart forums © 2001-2020