x
 
Create New Page
 View Previous Changes    ( Last updated by Michael Rog )

Category Archives with Custom Fields

Question:

I want a page that lists off the Category Name and then has custom fields from every post in that category listed before moving to the next Category Name and repeating the process. How can I accomplish this?

Answer:

In EE 2, this can be easily accomplished with the Category Sorted Entries plugin.

In EE 1.x, it requires nesting a {exp:weblog:entries} call in the {exp:weblog:category_archives} tag, which becomes very load intensive if you have more than a few entries:

Method 1 (for EE 1.x)

Les suggested this:

{exp:weblog:category_archive weblog="weblog1"

{categories} 
<h3>{category_name}</h3
{if category_description} 
<p>{category_description}</p
{/if} 


{exp
:weblog:entries weblog="weblog1" orderby="date" 
category="{category_id}" sort="asc" limit="50" 

Entry Title
: <a href="{title_permalink=">{title}</a
{comment_total} Comments<br /> 
<
p>{body}</p

{paginate} 

<div class="paginate"

<
span class="pagecount">Page {current_page} of {total_pages} pages</span
{pagination_links} 

</div

{/paginate} 

{
/exp:weblog:entries} 
{
/categories} 
{
/exp:weblog:category_archive} 

It is highly recommend making use of the paginate function in some fashion similar to what I show here if you have a lot of entires. In testing on a site with 2,000+ entries it took close to a minute to render the above and it was still loading the page when the browser window was closed.

Method 2 (for EE 1.x)

Another method is suggested further down in the relevant topic, by wsmith:

<table border="1"
{exp:weblog:categories weblog="weblog1" style="linear"
<tr
<
td
<
h3>{category_name}</h3
{if category_description} 
<p>{category_description}</p
{/if} 
</td
<
td
<
b>Stories</b><br /> 
{exp:weblog:entries weblog="discussion" category="{category_id}" 
{title}
<br /> 
{summary} 
<a href="Discussion">Discussion</a
{/exp:weblog:entries}<br /> 
<
br /> 
</
td
</
tr
{/exp:weblog:categories} 
</table

Question:

I want the Category Archive function to only list a limited number of latest entries per category rather than all entries per category?

Answer:

Here is how to list only 5 entries per category:

{exp:weblog:category_archive weblog="{weblog_name}"

{categories} 
{category_name} 


{exp
:weblog:entries weblog="{weblog_name}" orderby="date" category="{category_id}" sort="asc" limit="5" 

<a href="{title_permalink=">{title}</a
{comment_total} Comments<br /> 

{/exp:weblog:entries} 
{
/categories} 
{
/exp:weblog:category_archive} 

Category:Categories Category:Tricks

Category:EE1
Category:EE2

Categories: