Hi, Like everyone else, I am very grateful for this new plugin! It seems to be exactly what I need, however, I am having a little difficulty making the links to the Entries work.
I have a project where a Law Office has several “Areas of Practices” and each Area of Practice can have 0 - 30 Services associated with it (in other words, subcategories).
There is a page that will list all of these out, and the “Areas of Practice” and “Services” need to link to their respective details pages if content exists in their description field, otherwise they need to just display on the listing page with no link. Oh, and there will never be a “Services” entry without a description, though there my be an “Area of Practice” entry without description.
I have set up my Categories as such:
Area of Practice 1 - Service for 1
Area of Practice 2 - Service for 2
Area of Practice 3 - Service for 3
Area of Practice 4 - Service for 4
Area of Practice 5 - Service for 5
Area of Practice 6 - Service for 6
And so on…
When inputting content, there is a weblog called hr_areas_of_practice_and_services with the “title” field and a custom field called “description”.
My problem is that I cannot figure out a way to make the links work for the entries generated by your plugin. I fear that it may be because I am a novice, so please have mercy 😉
I have tried category_archive, but cannot get it to do what I want. I feel like I just don’t have the hang of it.
I have tried entries, but they don’t get me the nesting capabilities I require, though the links are correct.
And I have tried your code. It’s by far the closest to what I need. It’s just that the links aren’t correct. In the code below you will see what I am TRYING to do with the links.
Here is my code:
<h2>category_archive</h2>
{exp:weblog:category_archive weblog="hr_areas_of_practice_and_services" style="nested"}
{entry_titles}
<a href="http://{path=SITE_INDEX}">{title}</a>
{/entry_titles}
{/exp:weblog:category_archive}
<h2>entries has the right links, but doesn’t have the right nesting</h2>
<ul>
{exp:weblog:entries weblog="hr_areas_of_practice_and_services" sort="asc"}
{if description == ""}
<li>{title}</li>
{if:else}
<li><a href="http://{permalink=hr/areas_of_practice_services_2}">{title}</a></li>
{/if}
{/exp:weblog:entries}
</ul>
<h2>child_categories plugin has workable nesting, but doesn’t have the right links</h2>
{exp:child_categories weblog="hr_areas_of_practice_and_services" parent="50|51|52|53|54|55" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" entries_limit="6"}
{parent_category_start}
<h3><a href="http://{permalink=hr/areas_of_practice_services_2}">{parent_category_name}</a></h3>
{parent_category_end}
{child_category_start}
{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{permalink=hr/areas_of_practice_services_2}">{title}</a></li>
{entries_end}
{entries_wrapper_bottom_start}
</ul>
{entries_wrapper_bottom_end}
{/exp:child_categories}
A working sample (using the code above) can be found at http://hruhpa.com.s18903.gridserver.com/index.php/hr/areas_of_practice_listing/
I think the problem is centered around the fact that the {permalink} tag won’t work without being inside of the {exp:weblog:entries} tag, but I have exhausted my brain power trying locate it properly, so my code above has it not wrapping the permalinks. The way the loops are constructing when I put it in different places is driving me nuts!
If I need to create the links a different way, please tell me the best way to go about it. I’m sort of a newb.
If you are able to offer any help, that would be fantastic!!! Let me know if you need more details from me. And thank you very much.
Hi there,
Lovely plugin… but i’ve got a problem making an expandable navigation.
<ul class="navigation_main">
{exp:weblog:categories weblog="{embed:my_weblog}" category_group="1" show="not 8|13|14|15|16|17" style="linear"}
<li>
<a href="http://{path=SITE_INDEX}">{category_name}</a>
{if segment_2 == "print"}
{if category_id == "4"}
<li>
<ul class="navigation_subsub">
{exp:child_categories parent="4" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" entries_limit="3" site="1"}
{child_category_start}
<li><a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
</li>
{/if}
{/if}
</li>
{/exp:weblog:categories}
</ul>
In this case i have 4 main category buttons:
Print Web Motion Wall
The Print button contains subcategories:
Projects Graphic designers Illustrators Typographers Visualisers
Now with this if statement i try to figure out when the print category button was clicked:
{if segment_2 == "print"}
{if category_id == "4"}
But the problem is that when i click on a subcategory segment_2 doesn’t contain the “print” parameter anymore (cause it’s set to the subcategory) and my subnavigation will not appear.
I thought i would solve it by using:
{homepage}/category/{parent_category_url_title}/{child_category_url_title}
instead of
{homepage}/category/{child_category_url_title}
Now the subnavigation doesn’t disappear but the subcategory content won’t show.
How do i solve this problem??
Hi jdgraffam,
Yes, {permalink} variable will not work inside {exp:child_categories} tag.
To get links working you may write one of the several possible versions of code.
First, you may use {path=some_segment/some_segment/some_segment} global variable together with {url_title} variable of Child Categories plugin:
{entries_start}
<li><a href="http://{path=hr/areas_of_practice_services_2}{url_title}/">{title}</a></li>
{entries_end}
Alternatively, you can go Control Panel Home > Admin > Weblog Administration > Weblog Management > Edit Weblog > Path Preferences and set path preference for your weblog “hr_areas_of_practice_and_services”. Then you can use variable {weblog_url} together with {url_title} variable of Child Categories plugin:
{entries_start}
<li><a href="http://{weblog_url}/{url_title}/">{title}</a></li>
{entries_end}
Yet alternatively you can use your word triggering categories (which by default is “category”) together with {homepage} global variable and {child_category_url_title} and {url_title} variables of Child Categories plugin:
{entries_start}
<li><a href="http://{homepage}/category/{child_category_url_title}/{url_title}/">{title}</a></li>
{entries_end}
Use any version you like.
Hi phrz,
You should not wonder that something does not work when you use such complex nesting.
You place 1){if segment_2 == "print"} conditional inside {exp:weblog:categories} tag, and then you place 2) {if category_id == "4"} conditional which is part of {exp:weblog:categories} tag inside {if segment_2 == "print"} conditional.
Try to simplify your nesting and things should start to work.
If you nest some tags, build your nesting step-by-step checking every step if it works.
Hi Laisvunas,
Thanks for your quick reply. I’m quite new to EE and i thought this was a pretty basic nesting solution..
Is there a simple way to achieve a categorie -> click -> show subcategorie navigation in EE?
I mean it’s likely been done before, can you give me some directions (i’ve searched trough a lot of wiki posts and eeDocs)
Cheers!
Hi phrz,
Is there a simple way to achieve a categorie -> click -> show subcategorie navigation in EE?
Speaking generally, ExpressionEngine and most its plugins does not presuppose any HTML, CSS or Javascript. That is, what HTML, CSS or Javascript to include in your pages is entirely up to you.
Concerning your problem this implies that you should try to solve it in 2 steps:
1) you should find navigation menu script you like
2) you should find ExpressionEngine’s tag(s) or plugin(s) which would allow to pull data you need from database and insert it into your menu’s HTML.
Concerning the second step you may consider such ExpressionEngine’s tags as {exp:weblog:categories} or {exp:weblog:category_archive} or such plugins as Child Categories or Subcategories.
It seems that there is no simpler way to achieve what you need.
Hope that helps.
Hi, thanks for such a fast response! I certainly was pleased to start work this morning and have such a good start on my day’s work! Thank you!
I have taken your advice and gone with the first approach you suggested to construct my links, and that solved my issue with constructing links.
I only have one issue left to resolve, which I am hopeful you can help me with: for the parent categories that don’t have anything in the {description} field, I want to show them without a link, and if they have something in the {description} field, I want to show them with a link.
Here is my code, which shows what I am trying to accomplish. It just doesn’t seem that the {if} tag works inside the {exp:child_categories} tag. Am I missing something?
<h2>child_categories plugin</h2>
{exp:child_categories weblog="hr_aps" parent="50|51|52|53|54|55" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="6"}
{if description != ""}
{parent_category_start}
<h3><a href="http://{path=hr/areas_of_practice_detail}{parent_category_id}/">{parent_category_name}</a></h3>
{parent_category_end}
{if:else}
{parent_category_start}
<h3>{parent_category_name}</h3>
{parent_category_end}
{/if}
{child_category_start}
{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{path=hr/areas_of_practice_services_2}{url_title}/">{title}</a></li>
{entries_end}
{entries_wrapper_bottom_start}
</ul>
{entries_wrapper_bottom_end}
{/exp:child_categories}
Here is a link to my latest creation, based off of your previous advice. http://hruhpa.com.s18903.gridserver.com/index.php/hr/areas_of_practice_listing
And thank you again for making yourself and your talents so freely accessible. Once I get this resolved, I’d love to make a Paypal donation to you or your charity of choice. Just PM me the details.
Hi jdgraffam,
It just doesn’t seem that the {if} tag works inside the {exp:child_categories} tag.
Correct. Conditionals currently are not supported by Child Categories plugin.
Still, it seems that what you need can be achieved using Child Categories plugin together with {exp:weblog:categories} tag.
There are several things to be noted:
1) No code should be outside variable pairs {parent_category_start}{parent_category_end} {child_category_start}{child_category_end} {entries_start}{entries_end} {entries_wrapper_top_start}{entries_wrapper_top_end} {entries_wrapper_bottom_start}{entries_wrapper_bottom_end}
2) {exp:child_categories} tag must have parse=”inward” parameter.
3) Both {exp:child_categories} tag and {exp:weblog:categories} tag must have “weblog” parameter which specifies only one weblog.
The code should be approximately as follows:
{exp:child_categories weblog="hr_aps" parent="50|51|52|53|54|55" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="6" parse="inward"}
{parent_category_start}
{exp:weblog:categories style="linear" weblog="hr_aps"}
{if category_id=="{parent_category_id}" AND category_description!=""}
<h3><a href="http://{path=hr/areas_of_practice_detail}{category_id}/">{category_name}</a></h3>
{/if}
{if category_id=="{parent_category_id}" AND category_description==""}
<h3>{category_name}</h3>
{/if}
{/exp:weblog:categories}
{parent_category_end}
{child_category_start}
{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{path=hr/areas_of_practice_services_2}{url_title}/">{title}</a></li>
{entries_end}
{entries_wrapper_bottom_start}
</ul>
{entries_wrapper_bottom_end}
{/exp:child_categories}
Nice plugin. And for a noob like me, I actually sort of got it working. Here is my problem and hopefully someone will be able to help.
I am using this for a three tier navigation. I have the tiers specified as categories. Example:
About Us (Tier 1/Template) - HQ Location (Tier 2/Weblog) - Contact Information (Tier 2/Weblog) - - Email (Tier 3/Weblog) - - Phone (Tier 3/Weblog) - - Mailing (Tier 3/Weblog) - Business Principles (Tier 2/Weblog) Services (Tier 1/Template)
The page will have the tier 1 items across the top (never changes). Tier 2 and Tier 3 will be along the right side. Tier 2 on the top and Tier 3 on the bottom (using div within the templates)
Using the code below, when a person navigates to a Tier 2 page, the Tier 3 (child categories) appear in the bottom div on the right. The problem however, is once they have navigated to a Tier 3 page, the bottom navigation is now blank. From what I can understand and it makes sense, once they are on a tier 3 page; there are no child categories and therefor it will not show up. Is there a way using IF statements to have it where when they are on a tier 3 page it will continue to show the categories in the bottom div as if they are really on a tier 2 page? Remember I am using one template for both the Tier 2 and Tier 3 pages.
{exp:category_id category_group="8" category_url_title="{segment_2}” parse=”inward”} {exp:child_categories parent="{category_id}” site=”2” show_empty=”yes” entries_limit=”5” parse=”inward”} {child_category_start} {child_category_name} {child_category_end}
{/exp:child_categories} {/exp:category_id}
I saw something about using a sibling instead which seems to work when they on a a tier 3 but when on a tier 2 the page displays errors.
Notice: Undefined variable: parent_cat_description in /home/honourhe/public_html/hcsystem/plugins/pi.child_categories.php on line 474
Notice: Undefined variable: parent_cat_image in %SITEPATH%/plugins/pi.child_categories.php on line 475
Any ideas?
Is there a way using IF statements to have it where when they are on a tier 3 page it will continue to show the categories in the bottom div as if they are really on a tier 2 page? Remember I am using one template for both the Tier 2 and Tier 3 pages. {exp:category_id category_group="8" category_url_title="{segment_2}” parse=”inward”} {exp:child_categories parent="{category_id}” site=”2” show_empty=”yes” entries_limit=”5” parse=”inward”} {child_category_start} {child_category_name} {child_category_end} {/exp:child_categories} {/exp:category_id}
As I can see from your code, in Tier 2 pages you get category_url_title from segment_2 and convert it to category_id.
In order to show the same categories in Tier 3 pages you should somehow pass value of segment_2 from Tier 2 page to Tier 3 page. To do this most convenient way is to use some other URL segment variable (EXpressionEngine supports 9 URL segment variables).
Thanks for your reply Laisvunas.
Unfortunately, since I am using one template for both the tier 2 and tier 3 items, there is no segment_3 define. So, no matter if they are on a tier 2 or a tier 3 page, the url is still only index.php/About_Us/{page_name}.
Unless there is a way to make a tier 3 page become a segment_3 in the URL without having to make additional templates, is there?
So using the example:
About Us (Tier 1/Template) - HQ Location (Tier 2/Weblog) - Contact Information (Tier 2/Weblog) - - Email (Tier 3/Weblog) - - Phone (Tier 3/Weblog) - - Mailing (Tier 3/Weblog) - Business Principles (Tier 2/Weblog)
When on the Contact Information page the url is /index.php/Services/contact_info When on the Email page the page url is /index.php/Services/email
Is it possible to define the tier3 pages as segment_3 (/index.php/Services/contact_info/email) without having another template? If not, how else would I handle this problem?
Thanks
Unfortunately, since I am using one template for both the tier 2 and tier 3 items, there is no segment_3 define. So, no matter if they are on a tier 2 or a tier 3 page, the url is still only index.php/About_Us/{page_name}.
You can easily form URLs which are placed in Tier 2 pages and lead to Tier 3 pages this way:
ndex.php/About_Us/page_name/{segment_2}/
Then add simple conditional inside category_url_title parameter of exp:category_id tag:
{exp:category_id category_group="8" category_url_title="{if segment_2=="some_tier_2_segment" OR segment_2=="some_other_tier_2_segment"}{segment_2}{/if}{if segment_2=="some_tier_3_segment" OR segment_2=="some_other_tier_3_segment"}{segment_3}{/if}" parse="inward"}
{exp:child_categories parent="{category_id}" site="2" show_empty="yes" entries_limit="5" parse="inward"}
{child_category_start}
<a href="http://{homepage}/Services/{child_category_url_title}/">{child_category_name}</a>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}
This way you will pass segment_2 of Tier 2 page to Tier 3 page as its segment_3; and using conditional you will pass it as value of category_url_title parameter of exp:category_id tag.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.