Categories displayed with weblog entries
Posted: 25 August 2008 02:59 PM   [ Ignore ]  
Summer Student
Total Posts:  4
Joined  08-25-2008

I’m slowly picking up EE the more I play with it, but I’ve hit a dead-end. I currently have a weblog setup with mutiple categories in that weblog. What I’d like to do seems like it would be simple, but I’m having trouble figuring out the code. I would like to have a page to display all entries for weblog (small weblog) by category, with a category heading, something like this:

Category 1

Weblog Entry 1
Weblog Entry 2
Weblog Entry 3

Category 2
Weblog Entry 6
Weblog Entry 9

Category 3
Weblog Entry 4
Weblog Entry 5
Weblog Entry 7
Weblog Entry 8


I’ve tried this:

{exp:weblog:categories weblog="stuff"}

<p><span class="capitals"><strong>{category_name}</strong></span></p>


{exp:weblog:entries weblog="stuff" disable="comments|trackbacks|member_data"}
{stuff_image}
<strong>{name}</strong>
{stuff_detail}
{
/exp:weblog:entries}


{
/exp:weblog:categories}

but that has all the entries repeating in every category. Is there a way to display the weblog entries by category on a single page?

Profile
 
 
Posted: 25 August 2008 04:25 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-18-2007

Have you tried adding the categories parameter to the weblog entries tag?

http://expressionengine.com/docs/modules/weblog/parameters.html#par_category

{exp:weblog:entries category=”{category_id}” etc….}

Profile
 
 
Posted: 25 August 2008 05:06 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  4
Joined  08-25-2008
slapshotw - 25 August 2008 04:25 PM

Have you tried adding the categories parameter to the weblog entries tag?

http://expressionengine.com/docs/modules/weblog/parameters.html#par_category

{exp:weblog:entries category=”{category_id}” etc….}

If I go that route, how do I specify which category of the weblog to pull in the exp:weblog:categories statement? (I didn’t see that option in the documentation. I saw category_group, but since all the categories I want to pull are in the same category group, that doesn’t do me much good.) And if I do that, that means I’ll have to iterate each category/category_id manually in the template, right? I was hoping that there was some way to have all the categories for the weblog display dynamically, and have all the entries for each category show under the category heading dynamically as well.

Profile
 
 
Posted: 25 August 2008 05:48 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-18-2007

Exp:categories has a show= parameter:

http://expressionengine.com/docs/modules/weblog/categories.html#par_show

The show parameter will limit the categories tag to only certain categories, and then the weblog:entries tag will be dynamic based off that. You only need one of each tag to keep iterating.

Or did i misunderstand your goal?

Profile
 
 
Posted: 25 August 2008 06:20 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  4
Joined  08-25-2008
slapshotw - 25 August 2008 05:48 PM

Exp:categories has a show= parameter:

http://expressionengine.com/docs/modules/weblog/categories.html#par_show

The show parameter will limit the categories tag to only certain categories, and then the weblog:entries tag will be dynamic based off that. You only need one of each tag to keep iterating.

Or did i misunderstand your goal?

Ah, I missed the “show” parameter. Ok, here’s the code I’ve got now:

{exp:weblog:categories weblog="stuff" show="4"}
<strong>{category_name}</strong>

     
{exp:weblog:entries weblog="stuff" disable="comments|trackbacks|member_data" category="4"}
     
<p>{stuff_image}<strong>{name}</strong><br />
     
{stuff_detail}</p>
     
{/exp:weblog:entries}
{
/exp:weblog:categories}

{exp
:weblog:categories weblog="stuff" show="5"}
<strong>{category_name}</strong>

     
{exp:weblog:entries weblog="stuff" disable="comments|trackbacks|member_data" category="5"}
     
<p>{stuff_image}<strong>{name}</strong><br />
     
{stuff_detail}</p>
     
{/exp:weblog:entries}
{
/exp:weblog:categories}

etc
...

Is this what you were suggesting? I’m not sure if I’ve missed something else, or what, but only the first “statement” is pulling any data back, unfortunately, and only 1 of 2 entries in the first category. Right now I’ve got 3 entries in the weblog, entry 1 and 3 are labeled as category #1, and entry 2 is in category #2. The literal IDs for the category in this case per the control panel (Category Groups->Category Management) are 4 and 5, so I would think that the code in my example above would show the category name for category ID #4 and its two entries, then the category name for category ID #5 and it’s single entry. Unfortunately, that’s not what I’m seeing. I’d offer to let you take a look at the site, but it’s on a test server behind a firewall at work.

Edit: Btw, I’ve tried the above code with and without the “category=” parameter in the exp:weblog:entries tag. If I don’t include it, all weblog entries show, regardless of the category, if I do include it, only the first entry shows. =/ Am I missing something obvious? Are you allowed to next the exp:weblog:entries tag in the exp:weblog:categories tag?

Edit 2: Gah, I’m an idiot. The category wasn’t being set on one of the entries, hence why only 1 entry showed up for the first category. Phew. Ok, that answers that question.

I think this method will work for me, but if there is a better way to handle the code so it’s a bit more automatic (for example, if I add a new category for this weblog, I will need to add a section of code in the template that specifies the category ID for the new category…), I’d love to know. Thanks for all of your help!

Profile
 
 
Posted: 25 August 2008 06:57 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-18-2007

I would have done something similar to the following, using uncategorized_entries=“n” in the weblog:entries tag:

{exp:weblog:categories weblog="stuff" show="4|5|6"}
<strong>{category_name}</strong>

     
{exp:weblog:entries weblog="stuff" disable="comments|trackbacks|member_data" category="{category_id}" uncategorized_entries="n"}
     
<p>{stuff_image}<strong>{name}</strong><br />
     
{stuff_detail}</p>
     
{/exp:weblog:entries}
{
/exp:weblog:categories}

Profile
 
 
Posted: 25 August 2008 07:07 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  4
Joined  08-25-2008
slapshotw - 25 August 2008 06:57 PM

I would have done something similar to the following, using uncategorized_entries=“n” in the weblog:entries tag:

{exp:weblog:categories weblog="stuff" show="4|5|6"}
<strong>{category_name}</strong>

     
{exp:weblog:entries weblog="stuff" disable="comments|trackbacks|member_data" category="{category_id}" uncategorized_entries="n"}
     
<p>{stuff_image}<strong>{name}</strong><br />
     
{stuff_detail}</p>
     
{/exp:weblog:entries}
{
/exp:weblog:categories}


Cool, thanks! I wish I had thought to try using the {category_id} variable in the exp:weblog:entries tag. I think that’s where half my problem has been! Someday I’ll get the hang of all this. I’m hoping to push my CFO to let us purchase EE for our website at work, and getting this type of stuff under my belt will greatly help me make my case. Thank you again for all the help!

Profile
 
 
Posted: 25 August 2008 07:18 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-18-2007

No problem. Glad it’s working!

Profile
 
 
Posted: 17 September 2008 06:00 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  344
Joined  05-15-2004

Is there a way to not have the categories output themselves with:

<ul>
<
li></li>
</
ul>

It seem whenever they output, they automatically add this stuff in “for free”.

Note: I’ved rephrased this question and moved it here: http://expressionengine.com/forums/viewthread/91314/

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64912 Total Logged-in Users: 25
Total Topics: 81864 Total Anonymous Users: 17
Total Replies: 440101 Total Guests: 180
Total Posts: 521965    
Members ( View Memberlist )
Newest Members:  bjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkeybenekwhobutsb