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 June 17th, 2013, 12:56 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default If condition for child categories

Store ID: 42080

Hi,

I would like to display a category list IF there are any childs.
There is a widget that I can use for this but I need to display certain stuff before and after the list, stuff that don't work to place in the following line:

[category.list before=' ' after=' ']

Question: Is there any other PHP IF statement that I can execute in order to know if the certain category has childs?

Thanks in advance.
  #2  
Old June 17th, 2013, 01:04 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi,

Just a thought, could you display your extra stuff like this:

<p>stuff above list</p>
[category.list before=' ' after=' ']
...
[/category]
<p>stuff below list</p>

If not there are conditionals such as these:

HTML Code:
[category.if active='self']
	display if THIS category is active
[/category.if]

[category.if active='child']
	display if one of the child categories of this category is active
[/category.if]

[category.if active='parent']
	display if one of the parent cats is active
[/category.if]

[category.if active='no']
	category is not in "activity chain"
[/category.if]
You can read much more about the [category] loop here: http://www.datafeedr.com/docs/item/169

Eric
  #3  
Old June 17th, 2013, 01:17 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

Thanks for the feedback Eric.

I've tried those loops without any succes. This is my code:

HTML Code:
<div class="btn-group" style="margin-left: 13px;margin-top: 9px;"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Kategori<span class="caret"></span></a><ul class="dropdown-menu">
[category.list before='' after='']
<li style="list-style-type: none;margin:0px;">
<a href="[category.link]" title="[category.name]">[category.name]</a>
</li>
[/category.list]
</ul></div>

As you may see I'll be having an empty dropdown menu if the category list is empty. That's what I want a work-around for.

I tried placing everything before the [category.list before='' after=''] in the before='' field. And then placing the last line in the after='' field, which didn't work.

I've now tried to place the [category.if active='child'] loop before [category.list before='' after=''], didn't work. Then I simply removed the "category.list" and kept the "category.if active='child' but no succes there either.

Do you see any misstakes? Maybe I'm not do it right.

I don't get an error, the dropdown is simpy missing.

Last edited by nokii : June 17th, 2013 at 01:18 PM.
  #4  
Old June 17th, 2013, 01:20 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I think you need this:
HTML Code:
<div class="btn-group" style="margin-left: 13px;margin-top: 9px;">
	<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Kategori<span class="caret"></span></a>
	[category.list before='<ul class="dropdown-menu">' after='</ul>'] 
		<li style="list-style-type: none;margin:0px;"> <a href="[category.link]" title="[category.name]">[category.name]</a> </li>
	[/category.list] 
</div>
  #5  
Old June 17th, 2013, 01:29 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

Yes I do get the dropdown and its child categories but when I navigate to a category without childs I get an empty dropdown due to that the "div" is defined before the category.list

I also tried this but the dropdown won't show up at all in this case:

[category.if active='child']
<div class="btn-group" style="margin-left: 13px;margin-top: 9px;">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Kategori<span class="caret"></span></a>
[category.list before='<ul class="dropdown-menu">' after='</ul>']
<li style="list-style-type: none;margin:0px;"> <a href="[category.link]" title="[category.name]">[category.name]</a> </li>
[/category.list]
[/category.if]

== just added the category.if statement.

Any ideas?
  #6  
Old June 17th, 2013, 01:36 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I can't find this view in the Factory. What is its name?
  #7  
Old June 17th, 2013, 01:40 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

In my Store it's:

--> Views --> Category Page --> Default --> Category List

And in this module you'll find another dropdown at the top, this part is close to the bottom.
  #8  
Old June 17th, 2013, 01:45 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Can you remove the category.if statement you put on that and update your store again so I can see what's going on on your site?
  #9  
Old June 17th, 2013, 01:49 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

Updated!

http://fajnd.se/store/category/iphone-5/
  #10  
Old June 17th, 2013, 01:53 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi,

Try setting your "Maximum tree depth" to blank (ie. leave the field empty) here: The Factory > Your Store > VIEWS > CATEGORY PAGE > Default > Category list module > Settings ().

Eric
  #11  
Old June 17th, 2013, 01:56 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

Done. Now its logical, I should get the dropdown because there is no statement around it. So we need to define an if/loop statement so that we don't show it when there are no childs.
  #12  
Old June 17th, 2013, 02:06 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi,

You still need to change this:
HTML Code:
[category.list before='<ul class="dropdown-menu">' after='</ul>'] 
    <li style="list-style-type: none;margin:0px;"> <a href="[category.link]" title="[category.name]">[category.name]</a> </li>
[/category.list]
To this:
HTML Code:
[category.list before='<ul class="dropdown-menu">' after='</ul>'] 
    <li style="list-style-type: none;margin:0px;"> 
    	<a href="[category.link]" title="[category.name]">[category.name]</a>
    	[category.repeat]
 	</li>
[/category.list]
Eric
  #13  
Old June 17th, 2013, 02:13 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

Ok.

This is what I have right now:

<div class="btn-group" style="margin-left: 13px;margin-top: 9px;">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Kategori<span class="caret"></span></a>
[category.list before='<ul class="dropdown-menu">' after='</ul>']
<li style="list-style-type: none;margin:0px;">
<a href="[category.link]" title="[category.name]">[category.name]</a>
[category.repeat]
</li>
[/category.list]
</div>
  #14  
Old June 17th, 2013, 02:30 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi,

Try replacing this:
HTML Code:
[category.list before='<ul class="dropdown-menu">' after='</ul>'] 
    <li style="list-style-type: none;margin:0px;"> 
      <a href="[category.link]" title="[category.name]">[category.name]</a>
      [category.repeat]
   </li>
[/category.list]
With this:
HTML Code:
<?php if (!empty($category->children)) : ?>
	[category.list before='<ul class="dropdown-menu">' after='</ul>']
		<?php if (!empty($category->children)) : ?>
			<li class="dropdown-submenu" style="list-style-type: none;margin:0px;"> 
		<?php else : ?>
			<li style="list-style-type: none;margin:0px;"> 
		<?php endif; ?>
		  <a href="[category.link]" title="[category.name]">[category.name]</a>
		  [category.repeat]
	   </li>
	[/category.list]
<?php endif; ?>
Eric
  #15  
Old June 17th, 2013, 02:38 PM
nokii nokii is offline
 
Join Date: Jun 2013
Posts: 26
Default

You nailed it Eric
I just moved the initial IF statement to a higher level so that it surounded the <div class="btn-group"> as well and everything worked out well.

Many thanks! I won't be bugging you more today, it's beginning to get late in Sweden
  #16  
Old June 17th, 2013, 02:43 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by nokii View Post
You nailed it Eric
I just moved the initial IF statement to a higher level so that it surounded the <div class="btn-group"> as well and everything worked out well.
Excellent! I'm glad it worked for you.
 


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
Category URL parent/child tloenders Questions 1 November 8th, 2012 06:06 PM
Parent categories expand to show sub categories? gorman101 Problems 1 February 27th, 2012 08:24 PM
Custom Category View to apply to child categories too ayorofrance Feature Requests 0 January 20th, 2011 07:39 AM


All times are GMT -5. The time now is 12:55 PM.


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