Hi Jordan,
To show only 3 child categories use conditional as this:
{if "{child_category_count}" == "1" OR "{child_category_count}" == "2" OR "{child_category_count}" == "3"}
Some code
{/if}
To exclude individual child categories from list use conditional as this:
{if "{child_category_id}" != "10" AND "{child_category_id}" != "15" AND "{child_category_id}" != "21"}
Some code
{/if}
Hello, really need your help.
I am using this code:
{exp:child_categories category_group="2" entries_limit="none" status="open"}
{parent_category_start}
<a href="http://{site_url}services/category/{parent_category_url_title}">{parent_category_name}</a>
{parent_category_end}
{entries_start}
<a href="http://{site_url}services/detail/{url_title}/">{title}</a>
{entries_end}
{/exp:child_categories}
I however am getting no entries. What could be causing this?
Brad
Hi Laisvunas,
I have the following code -
{exp:weblog:categories category_group="1" show_empty="no" parent_only="yes" weblog="content_tutorials" style="linear"}
{exp:child_categories parent="{category_id}" show_empty="no" parse="inward" child_categories_sort_by="custom" child_categories_sort_direction="asc" entries_sort_by="date" entries_sort_direction="asc"}
{parent_category_start}
{if "{parent_category_children_count}" > "0"}
<h3><a href="http://">{parent_category_name}</a></h3>
<div class="lessons">
to download or view a lesson plan select from the lessons below
{/if}
{parent_category_end}
{child_category_start}
<h4><a href="http://">{child_category_name}</a></h4>
<div class="lessons_downloads">
{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{exp:single_field">{title} ({exp:single_field field="tutorials_file_type" entry_id="{entry_id}"})</a></li>
{entries_end}
{entries_wrapper_bottom_start}
</ul>
</div> <!-- lessons_downloads -->
{entries_wrapper_bottom_end}
{parent_wrapper_bottom_start}
</div> <!-- lessons -->
{parent_wrapper_bottom_end}
{/exp:child_categories}
{/exp:weblog:categories}
and my output comes out as -
<h3><a href="http://">Little Champs - 4-6 Years</a></h3>
<div class="lessons">
to download or view a lesson plan select from the lessons below
<h4><a href="http://">Little Champs Lesson B</a></h4>
<div class="lessons_downloads">
<ul>
<li><a href="http://">How to swing a raquet ()</a></li>
<li><a href="http://">Another Tutorial ()</a></li>
</ul>
</div> <!-- lessons_downloads -->
</div> <!-- lessons -->
</div> <!-- lessons -->
</div> <!-- lessons -->
</div> <!-- lessons -->
Any ideas how I can prevent these extra closing divs?
Hi stinhambo,
To quote from the reply #196:
New features: […] 4) support for {entries_total} and {child_category_id} variables inside {entries_wrapper_top_start}{entries_wrapper_top_end} variable pair. 5) support for {entries_total} and {child_category_id} variables inside {entries_wrapper_bottom_start}{entries_wrapper_bottom_end} variable pair. 6) support for {entries_total} and {child_category_id} variables inside {child_wrapper_bottom_start}{child_wrapper_bottom_end} variable pair. 7) support for {parent_category_children_count} and {parent_category_id} variables inside {parent_wrapper_bottom_start}{parent_wrapper_bottom_end} variable pair.
So, you can avoid unneeded closing tags by writing the code as here:
{entries_wrapper_bottom_start}
{if "{entries_total}" > 0}
</ul>
</div> <!-- lessons_downloads -->
{/if}
{entries_wrapper_bottom_end}
{parent_wrapper_bottom_start}
{if "{parent_category_children_count}" > 0}
</div> <!-- lessons -->
{/if}
{parent_wrapper_bottom_end}
Hi Laisvunas,
Your plugin works brilliantly. The one problem I am having though is that it is adding a huge number of queries to my page, in this case, 94. Using the code below, it generates a query for every parent category and every child category in the specified group.
Would you have any ideas as to why this would be?
{exp:child_categories weblog="{segment_1}" category_group="{embed:my_category_group}" show_empty="no" site="1"}
{parent_category_start}
<h5><a href="http://{homepage}{my_weblog}/region/category/{parent_category_url_title}/">{parent_category_name}</a></h5>
<ul class="list-type-0">
{parent_category_end}
{child_category_start}
<li><a href="http://{homepage}{my_weblog}/town/category/{child_category_url_title}/">{child_category_name} ({entries_total})</a></li>
{child_category_end}
{parent_wrapper_bottom_start}</ul><div class="clear listmargin"> </div>{parent_wrapper_bottom_end}
{/exp:child_categories}
Cheers, Calan
Hi Calan,
Child Categories plugin does many things; so, you should not wonder that it makes many calls to SQL server.
Of course, some calls might be saved by making SQL queries more efficient or by introducing “disable” parameter. But I doubt that such efficiency is really worth to strive at. If you do not have several thousands of categories or do not instantiate Child Categories plugin hundreds of times in one template you will hardly ever experience longer page load time or max out some PHP or SQL variable.
Hi Laisvunas,
Thanks for the reply. The problem is that it iterates through every category and sub-category and creates queries for each. I had a template that was generating over 2000 queries and was causing all sorts of problems to the server, but when removed, the same page uses 30 queries. This was purely to generate a couple of category lists which I’ve now done as static blocks.
Regards, Calan
Hi,
I have a download section on a website I am working on. It’s structured like this: Downloads - Download Section 1 - Download Section 2 - Download Section 3
On these pages I would like to display a download Adobe Reader link. So I hard coded it like this:
{if segment_2 == 'download' OR segment_2 == 'download-1' OR segment_2 == 'download-2' OR segment_2 == 'download-3'}
<a href="http://www.adobe.com/go/DE_CH-H-M-A1" title='Get Adobe Reader'>/images/site/icons/get_adobe_reader.png</a>
{/if}
This works fine until someone creates Download Section 4. Is there any way I can use your plugin to dynamically create that IF statement?
Thanks
Hi Andy,
In what way do the categories relate to the adobe reader?
You probably have a reason but it would seem you might be better off using a custom category field to store whether the category requires the adobe reader, or alternatively doing it on a product/entry basis where a custom field against the product/entry defines whether to display the link?
{if requires_adobe == "yes"}
<a href="#" title='Get Adobe Reader'>Adobe</a>
{/if}
Not sure this helps but difficult without knowing the context of what you’re trying to do.
C
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.