We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New "Subcategories" plugin available.

Development and Programming

Chris Curtis's avatar
Chris Curtis
17 posts
about 20 years ago
Chris Curtis's avatar Chris Curtis

You’re missing the closing {/exp:weblog:category_heading} tag and the opening {exp:weblog:entries} tag. Between those two, you should place the code for the new plugin.

       
livenomadic's avatar
livenomadic
6 posts
about 20 years ago
livenomadic's avatar livenomadic

The problem is that it only displays the top level categories. I have my Categories like this:

-Topics -Regions -Africa -Zimbabwe

It should display Zimbabwe, however it is displaying “Topics” and “Regions”

Here is my page:

http://www.technologyandchange.com/1/home/nav/topic/Africa/

Here is a new template:

<code>{assign_variable:master_weblog_name="tech"}
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>{exp:weblog:info weblog="{master_weblog_name}"}{blog_title}{/exp:weblog:info}</title>
<style type='text/css' media='screen'>@import "{stylesheet=home/index-style}";</style>
<style type='text/css' media='screen'>@import "{stylesheet=global/headfoot-style}";</style>
</head>
<body>
<div id="container">
{embed="global/header"}

<div id="nav">

</div>

<div id="content">
<div id="nav-menu">
<div id="title-box">

Topics

</div> <table id="nav-menu-table"> {exp:subcategories} <li>{category_name}</li> {/exp:subcategories} </table> </div> <div class="ad-box-2"></div> <div> <div id="title-box">

Recent Articles

</div> {exp:weblog:entries weblog="{master_weblog_name}" orderby="date" sort="desc" limit="15"} <div class="post"> <div class="post-title">

{title}

</div> <div class="post-details">By {author} on {entry_date format='%m/%d'}</div> <div class="post-summary">{summary}</div> <div class="post-options">Read More...</div> </div> {/exp:weblog:entries} </div> </div> {embed="global/footer"} </div> </body> </html></code>
       
MF's avatar
MF
15 posts
about 20 years ago
MF's avatar MF

Hi livenomadic

Regarding your wish to show the following:

a) Category Title b) List of Subcategories of that category c) List of Entries in this (current) category

Use a category that is passed to the template through the url and then place these tags in your template:

a) Use

{exp:weblog:category_heading} {category_name} {/exp:weblog:category_heading}

b) Use

{exp:subcategories …} {category_name} {/exp:subcategories}

c) Use

{exp:weblog:entries …} {title} {/exp:weblog:entries}

Also… How are your categories structured? With subcategories such as:

Topics —Regions ——Africa ———Zimbabwe ———Nigeria ——Europe ———France ———Germany

…or are they all on the same level?

(BTW… regarding your HTML code around the {exp:subcategories tag}. It would make more sense to use the “unordered list” tag <ul> in conjunction with <li> list items tag.>)

And…Here’s one example of how I use the plugin:

<style type="text/css">
<!--
.hide {
display: none;
}
.subcategories {
clear: both;
margin: 0;
padding: 15px 0 0 0;
width: 728px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
img {
border: none;
}
.subcategories h2 {
margin: 0;
padding: 3px 0 0 0;
font-size: 12px;
font-weight: bold;
color: #333;
/*border-top: 1px dashed #807cab;*/
background-image: url(/images/de-layout-basics-2/muster_2.png);
background-position: top;
background-repeat: repeat-x;
}
.subcategories ul {
float: left;
width: 728px;
margin: 0;
padding: 10px 0 0 0;
list-style-type: none;
}
.subcategories ul li {
float: left;
 width: 182px;
 margin: 0;
 padding: 0;
line-height: 1.618em;
font-size: 10px;
}
.subcategories li a {
color: #0033cc;
}
-->
</style>

<div class="subcategories">
  <h2>Kategorien</h2> 
  <ul>
     {exp:subcategories sort_by="category_name" count_entries_from_weblogs="22" count_entries_with_status="open|closed"}
    <li><a href="http://{template_path=templategroup/template}">{category_name} {if entries_count > 0}({entries_count}){/if}</a></li> 
    {/exp:subcategories} 
  </ul> 
</div>
       
livenomadic's avatar
livenomadic
6 posts
about 20 years ago
livenomadic's avatar livenomadic

When I paste:

{exp:subcategories} {category_name} {/exp:subcategories}

I am getting the wrong categories displayed.

The subcategories of:

http://www.technologyandchange.com/1/home/nav/topic/Africa/

is “Zimbabwe”

But as you can see it is displaying the categories “Regions” and “Topics”

       
MF's avatar
MF
15 posts
about 20 years ago
MF's avatar MF

@ livenomadic

From your url http://www.technologyandchange.com/1/home/nav/topic/Africa/ I assume that you are using category names In links? Unfortunately the plugin doesn’t support that yet. Maybe you could use numeric category indicators instead?

       
livenomadic's avatar
livenomadic
6 posts
about 20 years ago
livenomadic's avatar livenomadic

Ahhhh!

Thank you so much MF and everyone. I was bumfuzzled.

Thanks for the plugin MF!

P.S.: Feature Request: Works with Category Names On. :cheese:

       
Chris Curtis's avatar
Chris Curtis
17 posts
about 20 years ago
Chris Curtis's avatar Chris Curtis

Just to make sure we’re all clear: in this URL

http://www.technologyandchange.com/1/home/nav/topic/Africa/

1 = renamed “index.php” home = Template Group nav = Template topic = category “trigger” word Africa = category name

Is that all correct?

       
livenomadic's avatar
livenomadic
6 posts
about 20 years ago
livenomadic's avatar livenomadic

Yep

I turned off the named category urls to make the plugin work, but yes, that was the structure I plan to use once someone adds that feature.

It really surprised me that expressionengine doesnt already have the subcategories tag, are there any plans to add it?

       
Mr. Wilson's avatar
Mr. Wilson
131 posts
19 years ago
Mr. Wilson's avatar Mr. Wilson

Hey MF, thanks for the great plugin. Like livenomadic I want to use category names rather than category IDs in my URLs. I achieved that by modifying the url_root_node function. Please contact me if you would like to discuss integrating my changes into the official version of the plugin.

And just to head off any potential requests, I will not distribute my modified version of MF’s plugin unless MF gives me explicit permission to do so. I suspect MF would rather release an official updated version of the plugin rather than have an unofficial version get into the wild.

       
livenomadic's avatar
livenomadic
6 posts
19 years ago
livenomadic's avatar livenomadic

any reply from MF yet?

       
Mr. Wilson's avatar
Mr. Wilson
131 posts
19 years ago
Mr. Wilson's avatar Mr. Wilson

I have e-mailed MF, but I haven’t heard back.

       
MediaGirl Inc.'s avatar
MediaGirl Inc.
186 posts
19 years ago
MediaGirl Inc.'s avatar MediaGirl Inc.

I would very much like this module to show the category names as well… using the category id is terrible for search engines! Please post the hack for this or PM me.

       
MF's avatar
MF
15 posts
19 years ago
MF's avatar MF

There’s a difference between category names and category ID’s. In EE, category names are not unique, whereas category id’s are. I’ve discussed this with Mr. Wilson and he agrees that this could cause conflicts. We think that the only way to avoid them would be, to manually ensure that you use unique category names. Since I don’t want to rely on this, I’ve decided not to add Mr. Wilson’s first suggested code to this plugin.

However Mr. Wilson then came up with another solution/approach, using segments to identify even duplicate category names.

Example: http://example.com/index.php/categories/category_name/subcat_name/subsub_name/

He might want to share it with you. So that you can add those changes to the plugin.

       
Mr. Wilson's avatar
Mr. Wilson
131 posts
19 years ago
Mr. Wilson's avatar Mr. Wilson

mediagirl,

Check your inbox. I sent you an e-mail.

Folks who want to see my modification of MF’s plugin in action can visit http://lincolnite.com/directory/. The website is a work-in-progress.

       
PXLated's avatar
PXLated
1,800 posts
19 years ago
PXLated's avatar PXLated

Mr. Wilson… How did you get around the problem?

       
1 2 3 4 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.