Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Questions
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 26th, 2011, 08:26 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default Show all sub-categories for a specific parent category

Great post - am looking to do something similar...

However I would like to hide the top level in the list (as this will appear as the widget header) and show all sub categories when the parent is selected - like in the 'normal' category widget...

I'm not quite sure how this category.list loop works, so I tried the following in the hope that the outer loop would pick up on the top category, and the second loop would run through the children:
Code:
[category.list id=no1]

<?php if ($category->id == 544335 || $category->parent == 544335) { ?>

[category.list id=no2 before='<ul>' after='</ul>']

  [category.if active='self']
    <li>
      <strong><a href="[category.link]" title="[category.name]">[category.name] ([category.count])</strong>
      [category.repeat id=no2]
    </li>
  [/category.if]
  
  [category.if active='child']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name] ([category.count])</a>  
      [category.repeat id=no2]
    </li>
  [/category.if]
  
  [category.if active='parent']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name] ([category.count])</a>  
    </li>
  [/category.if]
  
  [category.if active='no']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name] ([category.count])</a>
    </li>
  [/category.if]
[/category.list]
<?php } ?>    
[/category.list]
However it didn't really work... so I have obviously not understood how the category lists work :-(

Is there an easy way to do this?

Thanks!
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #2  
Old January 26th, 2011, 08:38 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

So you just want to show all sub-categories of a parent category but only when the parent category ID has been selected?
  #3  
Old January 26th, 2011, 10:17 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Yes, basically just grab one top level category and show navigation for all sub-categories for this item...

To expand on the example above...

Code:
Sports
-> Football
    -> Jerseys
    -> Shorts
        -> Mens
        -> Womens
-> Baseball
Outdoors
-> Tents
-> Boats
I want to show one top level category in a widget:

Code:
Widget Title: Sports
-> Football
    -> Jerseys
    -> Shorts
        -> Mens
        -> Womens
-> Baseball
Is this possible?

Thanks!!
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #4  
Old January 27th, 2011, 09:20 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Question moved to its own thread.
  #5  
Old January 27th, 2011, 09:26 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

This will require 2 views to be set up:
  1. Create a new Widget view
  2. Give the widget title the parent category name
  3. Add a Text module to the view
  4. Add the following text to the Text module:
    Code:
    [DFR:onlysubcats?c=517926]
    where 517926 it the ID of the parent category.
  5. Create a new Custom view
  6. Give it the name "onlysubcats".
  7. Add a Category list module to the view
  8. Paste in the following code.
    HTML Code:
    [category.list before='<ul>' after='</ul>']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name]</a>
      [category.repeat]
    </li>
    [/category.list]
  9. In the Category list options, choose "Only child categories"
  10. Update your stores settings
  11. Add the new widget (the one with the Text module) to your sidebar.
That should do it.

Eric
  #6  
Old January 27th, 2011, 06:41 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Brilliant! Works a treat...

Is the [category.if active='self'] supposed to work in this context too?

Thanks a bunch for your help!
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #7  
Old January 27th, 2011, 06:51 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Yes, that will work in there, too. You might need to replace the code with the category list Template 1 code.
  #8  
Old January 27th, 2011, 07:48 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Works fine - apart from expanding child categories for the selected item...

At the moment I have the stock standard template 1 code, and still no luck...

My shop id is 30208...

Any other ideas as to what I might try?

Thanks!
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #9  
Old January 27th, 2011, 07:50 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I don't know... what are you trying to accomplish?
  #10  
Old January 27th, 2011, 08:00 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Sorry, I am not being very clear :-)

From:
Code:
-> Football
    -> Jerseys
    -> Shorts
        -> Mens
        -> Womens
-> Baseball
Using Football as the top level category I see:
Code:
    -> Jerseys
    -> Shorts
Which is cool, however when I click on Shorts it does not expand to show Mens and Womens...
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #11  
Old January 27th, 2011, 08:01 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

What's your store's ID and view name?
  #12  
Old January 27th, 2011, 08:04 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Store ID 30208

View names "Category - Lunette de soleil" and "onlysubcats"
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #13  
Old January 27th, 2011, 08:06 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I updated your view. See if that works. If it does, I will tell you what I did.
  #14  
Old January 27th, 2011, 08:07 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

It expands all sub categories even if they are not selected...
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #15  
Old January 27th, 2011, 08:10 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by ayorofrance View Post
It expands all sub categories even if they are not selected...
Oops, sorry, try again.
  #16  
Old January 27th, 2011, 08:17 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

same same...
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
  #17  
Old January 27th, 2011, 08:24 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I don't think we can get it to work as we are setting the "active" category here: [DFR:onlysubcats?c=517926]

That basically says, "When generating this category menu, treat category ID 517926 as the active category at all times".
  #18  
Old January 27th, 2011, 08:31 PM
ayorofrance ayorofrance is offline
 
Join Date: Sep 2010
Posts: 430
Default

Okay, no problem...

I suspect there is no easy way to check upwards in the tree to see if a parent has a given id?

I tinkered with a condition of this nature:
Code:
[category.list before='<ul>' after='</ul>']
<?php $pos = strpos($category->name,"xxxx");
  if ($pos != false) { ?>
  ....
which actually works fine if you have a common part of the category name you can select on...

Anyways, not to worry...

Thanks for trying!
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out.

Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
v1 to v3 Modules Utilizing Attributes, Click/PV Popularity, Specific Categories cspdfadmin Upgrading from V1 to V3 1 January 23rd, 2011 11:10 AM


All times are GMT -5. The time now is 02:05 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.