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 April 27th, 2011, 11:11 PM
wccoder wccoder is offline
 
Join Date: Apr 2011
Posts: 4
Default Sub-categories and datafeedr_tag

Store ID: 30226

Hey there,

I'm trying to create a sub-nav, which will contain only child categories of the current category.

I've created a custom view called "SubCategory List" which contains the following code :

Code:
[category.list before='<ul class="secondary-nav">' after='</ul>']
  [category.if active='parent']
    [category.repeat id='dfchild']
  [/category.if]
[/category.list]
I've tried other variations checking for active='child', active='self' and no dice.

On the WP side, the function I'm using is:

Code:
function get_sub_categories()
{
	echo str_replace(array('<div>', '</div>'),
									 array('', ''),
									 datafeedr_tag('SubCategory List?c=%ci'));
}
I'm unable to retrieve just the sub-categories of the currently active category. I was able to get a top-level category menu and apply a CSS class to the currently-active category with only a small issue (mainly there is no [category.else] - I needed to use active='no' for this case.)

Thanks for making Datafeedr so hackable.

-e.
  #2  
Old April 28th, 2011, 09:16 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Here's how that can be done:

1. Create a Custom View with the following settings:



2. Add a Category List module to that view.

3. Add the following code to the Category List module:
HTML Code:
[category.list before='<ul>' after='</ul>']
<li>
  <a href="[category.link]" title="[category.name]">[category.name]</a>
  [category.repeat]
</li>
[/category.list]
4. Configure the Category List module like this:



5. Create a new Widget View.

6. Add a Text module to your new Widget View.

7. Add the following code to the Text module template area:

PHP Code:
<?php
if ($category->id) {
    
$subcats datafeedr_tag('subcats?c=%ci');
    if (
strlen($subcats) > 170) {
        echo 
'<h3>'datafeedr()->category_name($category->id) . '</h3>';
        echo 
$subcats;
    }
}
?>
8. Update your store's settings

9. Add the new widget to your sidebar.

If you just want to add the code manually to your sidebar, add the code from step 7 to your template file.

Eric
  #3  
Old April 28th, 2011, 11:44 AM
wccoder wccoder is offline
 
Join Date: Apr 2011
Posts: 4
Default

That did exactly what I needed - I wasn't aware of the Category List settings panel - thanks for your quick response and such a great product!
 


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


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


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