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 February 28th, 2011, 12:32 PM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default Show One Sub Category Only in Category Widget

Hi Eric,

I am sure this is totally easy, but the function to do it in V3, just doesn't seem to be there.

I am converting another store over to V3. Currently this store has 5 parent categories: http://factory3.datafeedr.com/feeder/shop?shop=6202

However on the live website, I want to put the category widget in the side bar, but I want it to display only the sub categories, from one of the parent categories. This was achieved easily in V1 by just selecting that sub category from the category widget, but this doesn't seem to be possible in V3.

And from within the factory, I would have thought I could put a custom query string in, to just display that category, but it isn't available on the Category List module.

Ok, so tell me I am crazy and this is easy to achieve, but I am just missing something here?
  #2  
Old February 28th, 2011, 02:20 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Yes, this is possible.
  1. Create a new Custom view (example: name is 'subcats')
  2. Add a Category list module to the new view
  3. Add the following code to the view:
    Code:
    [category.list before='<ul>' after='</ul>']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name]</a>
      [category.repeat]
    </li>
    [/category.list]
  4. Set the category list module to Show: "Only child categories"
  5. Create a new Widget view
  6. Add a Text module to the view
  7. Add the following code to the Text module: [DFR:subcats?c=123456] (where subcats is the name of the custom view module and 123456 is the ID of the parent category)
  8. Click [Update Settings Only]
  #3  
Old February 28th, 2011, 07:40 PM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default

Right, that looks much more complicated than the previous way we did it... but that is the price we pay for being able to customize V3 so much!... and that is a good thing.

Thanks for the tip.

Not that I had tried it yet, but I was going to add a PHP text box widget in Wordpress and do this:
<?php echo datafeedr_tag("widget/categories?c=314811"); ?>

Would that also have worked?
  #4  
Old February 28th, 2011, 07:49 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Yes, there is an inverse relationship between simplicity and customizability.

Yes, you can replace any DFR shortcode with the datafeedr_tag() function. So in my example above, you could have also done this:

<?php echo datafeedr_tag("subcats?c=123456"); ?>
  #5  
Old March 4th, 2011, 07:42 PM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default

Hi Eric,
I have successful upgraded the store and this feature above worked fine.
Just a small issue I would like to fix.
When you are on a certain category, I would like that category to be highlighted, or not hyperlinked as it normally is.

You said above to use this:
PHP Code:
[category.list before='<ul>' after='</ul>']
<
li>
  <
a href="[category.link]" title="[category.name]">[category.name]</a>
  [
category.repeat]
</
li>
[/
category.list] 
But I used this instead, aiming for the not hyperlinked active category:
PHP Code:
[category.list before='<ul>' after='</ul>']
    
  [
category.if active="self"]
    <
li>
      [
category.name]
      [
category.repeat]
    </
li>
  [/
category.if]
  
  [
category.if active="child"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
      [
category.repeat]
    </
li>
  [/
category.if]
  
  [
category.if active="parent"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
    </
li>
  [/
category.if]
  
  [
category.if active="no"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>
    </
li>
  [/
category.if]
    
[/
category.list]&#8203; 
But as you can guess, it didn't work.
Why does this same code from the normal Category Widget not work?
Any suggestions on how to get it to work?
  #6  
Old March 5th, 2011, 08:55 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

That's a limitation of this method because the way it is, the targeted parent category is always 'active'.
  #7  
Old March 6th, 2011, 11:35 AM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default

Eric, It is not good enough. It was a function that was available in V1 and now suddenly it is not available in V3, even though V3 is meant to be more customizable. We need to find a solution to this.

I have tried a few different ways to get the category widget to display, but can't solve the issue of it not highlighting the active category.

One solution, that would suffice for me for the moment, until we find a better solution, is to just have my full tree displayed on every page.
I can not however get this to work.

On the Category widget in the Factory, I have the options set to FULL TREE and have 3 written in as the tree depth, however when I add the Datafeedr category widget to the sidebar, it only shows the parent categories. When I click on the sub category, it shows the child categories. However I want it to display the FULL tree from the start. Why does it not do this?

For this store, I have 5 parent categories, but only one of them has sub categories. It was that one that I wanted to only show in the sidebar navigation. However I don't like it not having active category different in some way. So I will put the full 5 categories in the navigation, if you can show me how to have it display all the sub categories too.
  #8  
Old March 6th, 2011, 12:40 PM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default

Ok, I have managed to get the following code to work:

PHP Code:
[category.list id='dfparent' before='<ul>' after='</ul>']

<
li>
   <
a href="[category.link]" title="[category.name]">[category.name]</a>  
 
  [
category.list id='dfchild' before='<ul>' after='</ul>']
  
  [
category.if active="self"]
    <
li class="active">
      [
category.name]
    </
li>
  [/
category.if]
  
  [
category.if active="child"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
    </
li>
  [/
category.if]
  
  [
category.if active="parent"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
    </
li>
  [/
category.if]  
  
  [
category.if active="no"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>
    </
li>
  [/
category.if]
  
 [/
category.list]
</
li>
[/
category.list]&#8203; 
However, this is not 100% correct. It displays all my parent and sub categories correctly, from the start and it highlights the active sub category. The only thing it doesn't do is highlight an active parent category.
I tried a few things and couldn't get it to work.
I am guessing I need some sort of statement in there which is [category.if active="self"] AND [category.if active="parent"], but I don't know how to do that.
Any ideas?

Also, what exactly does the
PHP Code:
[category.repeat id='dfchild'
do? As I removed it and it seems to make no difference.
  #9  
Old March 6th, 2011, 01:21 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

Try this (be sure to replace 123456 with your parent category ID:
HTML Code:
<?php $catids = array(); ?>

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

	<?php
	global $catids;
	if ($category->id == 123456 || in_array($category->parent, $catids)) {
		$catids[] = $category->id;
	?>
	
	[category.if active="self"]
		<li class="active">
			[category.name]
			[category.repeat]
		</li>
	[/category.if]
	
	[category.if active="child"]
		<li>
			<a href="[category.link]" title="[category.name]">[category.name]</a>  
			[category.repeat]
		</li>
	[/category.if]
	
	[category.if active="parent"]
		<li>
			<a href="[category.link]" title="[category.name]">[category.name]</a>  
		</li>
	[/category.if]
	
	[category.if active="no"]
		<li>
			<a href="[category.link]" title="[category.name]">[category.name]</a>
		</li>
	[/category.if]
	
	<?php } ?>

[/category.list]

Quote:
Originally Posted by patagonia View Post
Also, what exactly does the
PHP Code:
[category.repeat id='dfchild'
do? As I removed it and it seems to make no difference.
It allows you to format a list within that loop in a different way than it's parent loop. It's covered in more detail in example 2 on this page: http://www.datafeedr.com/docs/item/169
  #10  
Old March 6th, 2011, 01:23 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quick note, you don't have to set up 2 views for my previous code to work. Just create a new Widget view, add a category list module and then add that code.
  #11  
Old March 6th, 2011, 06:21 PM
stefan stefan is offline
 
Join Date: Feb 2008
Posts: 5,901
Default

Quote:
Originally Posted by patagonia View Post
One solution, that would suffice for me for the moment, until we find a better solution, is to just have my full tree displayed on every page. I can not however get this to work.

On the Category widget in the Factory, I have the options set to FULL TREE and have 3 written in as the tree depth, however when I add the Datafeedr category widget to the sidebar, it only shows the parent categories. When I click on the sub category, it shows the child categories. However I want it to display the FULL tree from the start. Why does it not do this?
To make this work you should override the category list template code in your Widget: Categories view with one of the templates that show subcategories.

Last edited by stefan : March 6th, 2011 at 06:26 PM.
  #12  
Old March 6th, 2011, 06:43 PM
patagonia patagonia is offline
 
Join Date: May 2009
Posts: 506
Default

Stefan and Eric,
Sorry I forgot to mention above that I had actually put the code, straight into the standard Categories Widget. I was no longer using custom view, or a custom view widget.

However, that code above didn't work. It produced this error:
PHP Code:
Warningin_array() [function.in-array]: Wrong datatype for second argument in /home/xxxxx.com/wp-content/plugins/datafeedr/datafeedr.php(1981) : eval()'d code on line 16 
However, I got the following code to work for me... it is dodgy, as it won't work for different categories. However works, in my case, I only had one sub category I was wanting to show.

PHP Code:
[category.list id='dfparent']

  [
category.list id='dfchild' before='<ul>' after='</ul>']
  
  [
category.if active="self"]
    <
li class="active">
      [
category.name]
    </
li>
  [/
category.if]
  
  [
category.if active="child"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
    </
li>
  [/
category.if]
  
  [
category.if active="parent"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>  
    </
li>
  [/
category.if]  
  
  [
category.if active="no"]
    <
li>
      <
a href="[category.link]" title="[category.name]">[category.name]</a>
    </
li>
  [/
category.if]
  
 [/
category.list]
[/
category.list]&#8203; 
 


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
'Home' in the category widget lbuilta59 Questions 1 February 5th, 2011 12:57 PM


All times are GMT -5. The time now is 10:32 PM.


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