ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Category: How to control what's on this page?

July 20, 2007 7:02pm

Subscribe [3]
  • #1 / Jul 20, 2007 7:02pm

    James Prickitt

    77 posts

    When I go to a category page, it uses the index template.

    I want it to show either:

    a) An excerpt of the 5 most recent entries

    or

    b) a list of entries in that category and one of the custom fields for each entry

    Right now all I see is the full text of all articles.


    Does it need its own template, or what do I put into the index template to show something different?

  • #2 / Jul 22, 2007 12:12am

    James Prickitt

    77 posts

    So I found the spot on the index template that says ” {if:elseif segment_2 != "topic"}”

    But I can’t output the category custom fields. What code do I need to put around

    {category_description}

    or what I really want to do is have a custom category field value show up. All the combinations I did don’t seem to work.

    This outputs the category title, but not for any of the other category fields:

    {exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="1"}
    {if segment_2 == "topic"}
    {categories}
    <h1>{category_name}</h1>
    {/categories}
    {/if}
    {/exp:weblog:entries}
  • #3 / Jul 22, 2007 11:15am

    James Prickitt

    77 posts

    Also, nothing gets output when I use the Category Heading tag:

    {exp:weblog:category_heading}
    
    <h1>{category_name}</h1>
    
    {if category_description}
    {category_description}
    {/if}
    
    {/exp:weblog:category_heading}
  • #4 / Jul 22, 2007 8:04pm

    Boyink!

    5011 posts

    OK…let’s just make sure some basics are in place:

    - You have a weblog.
    - You have a category group with categories, descriptions and a custom category field of some sort.
    - You have the category group assigned to the weblog.
    - You have posts in the weblog assigned to the categories.

    OK - on to the code.  You mention a if statement looking at for a “topic” value—is that the value you’ve setup as your keyword to tell EE you want a category page (under admin > weblog preferences > global weblog preferences)?  The default is “category” - so I assume you’ve changed it.

    Now - we need to see the code for the whole template, and how you’re linking to it.  Do you have nav being built with the weblog:categories tag?

  • #5 / Jul 25, 2007 10:14am

    James Prickitt

    77 posts

    Thanks for the help!

    OK…let’s just make sure some basics are in place:

    - You have a weblog.

    Yes.

    - You have a category group with categories, descriptions and a custom category field of some sort.

    Yes.

    - You have the category group assigned to the weblog.

    Yes.

    - You have posts in the weblog assigned to the categories.

    Yes.

    OK - on to the code.  You mention a if statement looking at for a “topic” value—is that the value you’ve setup as your keyword to tell EE you want a category page (under admin > weblog preferences > global weblog preferences)?  The default is “category” - so I assume you’ve changed it.

    Yes.

    Now - we need to see the code for the whole template, and how you’re linking to it.  Do you have nav being built with the weblog:categories tag?

    Index.php which is embedding _body.php—basically what was in index before:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    {embed="{my_template_group}/_header" pagetitle="{pagetitle}" metad="{metad}" metak="{metak}"}
    <!--blog/index-->
    {embed="{my_template_group}/_body"}
    {embed="{my_template_group}/_side"}
    {if segment_2 == ""}{embed="{my_template_group}/_footer" closing=""}
    {if:else}{embed="{my_template_group}/_footer" closing="{closing}"}
    {/if}

    _body.php - I’ve tried a number of versions but here is the current one:

    {exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="1"}
    {if segment_2 == "topic"}
    {categories}
    <h1>{category_name}</h1>
    {/categories}
    {/if}
    {/exp:weblog:entries}
    
    
    
    
    
    {exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="15"}
    
    <!-- entry -->
    <div class="entry">
    <div class="entry-title"><h3><a href="http://{url_title_path=">{title}</a></h3><p></div></p>
    
    <p>{if segment_2 == ""}<br />
    {summary}</p>
    
    <p>{if:elseif segment_2 != "topic"}<br />
    {body}<br />
    {extended}<br />
    <div class="entry-info"></p>
    
    <p>{if allow_comments}<br />
    ({comment_total}) Comments • <br />
    {/if}</p>
    
    <p>{if allow_trackbacks}<br />
    ({trackback_total}) <a href="http://{url_title_path=">Trackbacks</a> • <br />
    {/if}<br />
    <a href="http://{url_title_path=">Permalink</a> • <br />
    {entry_date format=' %l, %F %d, %Y '}</p>
    
    <p><br />
    More articles on:<br />
    {categories}<br />
    <a href="http://{path={my_template_group}}">{category_name}</a><br />
    {/categories}</p>
    
    <p><br />
    </div><br />
    {if:else}<br />
    {summary}<br />
    {/if}</p>
    
    
    
    <p></div><br />
    <!-- entry --></p>
    
    <p>{paginate}<br />
    <div class="navi-pages"><br />
    Page {current_page} of {total_pages} pages {pagination_links}<br />
    </div><br />
    {/paginate}</p>
    
    <p>{/exp:weblog:entries}

  • #6 / Jul 25, 2007 10:19am

    James Prickitt

    77 posts

    And just for the record, how to link has really confused me.

  • #7 / Jul 25, 2007 10:22am

    Boyink!

    5011 posts

    Where is {my_weblog} being assigned?

  • #8 / Jul 30, 2007 3:19pm

    James Prickitt

    77 posts

    In path.php, in the root directory for this site:

    $global_vars = array(
          “my_weblog” => “blog”,
          “my_weblog_name” => “blog”,
          “my_template_group” => “blog”
    );

  • #9 / Jul 30, 2007 5:47pm

    James Prickitt

    77 posts

    Can someone post code that works for them to display a custom category field?

    Two more hours today spent on this, it’s crazy.

    I have a custom category field named “pagetitle.”

    I can output a {category_name} and {category_description}.

    So RIGHT NEXT TO IT, I should be able to call it using {pagetitle}, right?

  • #10 / Jul 31, 2007 11:00am

    e-man

    1816 posts

    Haven’t really tested cat custom fiels yet but a quick test on a template reveals the following: (Cat 16 “books” has a cat custom field assigned to it called {testing}  with the value “book test custom field” for the cat custom field.
    This

    {exp:weblog:categories weblog="newblog" show="16"}
    {testing}
    {/exp:weblog:categories}

    generates this:

    <ul id="nav_categories" class="nav_categories">
        <li>
    book test custom field
    </li>
    </ul>

    So basically a list of your custom field values. Where the id and class are generated I don’t know, frankly.
    This:

    <h2>Categories</h2>
    <p><ul id="categorylist"><br />
    {exp:weblog:category_archive weblog="{master_weblog_name}" show_empty="no" style="linear" orderby="date" sort="desc" show="16"}<br />
    {categories}<li></p><h2>{category_name}{testing}</h2><p></li>{/categories}</p>
    
    <p>{entry_titles}<li><a href="http://{path=blog/index}">{title}{testing}</a></li>{/entry_titles}</p>
    
    <p>{/exp:weblog:category_archive}<br />
    </ul>

    generates this

    <h2>Categories</h2>
    <p><ul id="categorylist"><br />
    <li></p><h2>booksbook test custom field</h2><p></li><li><a href="http://www.stookstudio.com/index.php/blog/transcending_css/">Transcending CSS{testing}</a></li><br />
    </ul>

    As you can see it’s parsed correctly in the h2 tag but unparsed in the <a>‘s.
    Hope this helps in any way.

  • #11 / Jul 31, 2007 5:15pm

    James Prickitt

    77 posts

    Thanks for testing that.

    But neither of those is working.

    Something in my setup must be screwed up - Argh! I have no idea where.

  • #12 / Jul 31, 2007 5:28pm

    e-man

    1816 posts

    3 more things to try:
    1. Double-check all the things Boyink already mentioned regarding your setup.
    2. Try declaring your weblog - template group in your template itself instead of via the globals array.
    3. Try different names, right now they’re all called “blog’, this may cause confusion somewhere.

    I feel your pain man, I hope someone else chimes in as well.

  • #13 / Jul 31, 2007 5:41pm

    James Prickitt

    77 posts

    Ok here’s a puzzler:

    I have the Multiple Site Manager installed—

    It works on the other site that I developed first.  🐛 Yes, I set up the first site differently—but I’ve gone through so many changes that I don’t know what the difference could be.


    * Is it the URL? What should the URL be?

    GOOD:
    http://www.site-1.com/index/topic/finance/

    BROKEN:
    http://www.site-2.com/blog/topic/finance/
    http://www.site-2.com/index/blog/topic/finance/
    http://www.site-2.com/blog/index/topic/finance/
    http://www.site-2.com/blog/topic/index/finance/
    http://www.site-2.com/blog/topic/finance/index/


    - SITE-2: blog is a template group
    - SITE-1: I took out the template group from the URL with .htaccess and other stuff


    * Incomplete removal of the template group?

    - SITE-2: I was taking out the template group but hit snags and have been putting it back in.

  • #14 / Jul 31, 2007 5:42pm

    James Prickitt

    77 posts

    This is the code that works on the first site:

    {exp:weblog:categories weblog="blog" show="7"}
    H1: {h1}
    H2: {h2}
    pagetitle: {pagetitle}
    shorttitle: {shorttitle}
    metad: {metad}
    metak: {metak}
    closing: {closing}
    {/exp:weblog:categories}
  • #15 / Jul 31, 2007 7:33pm

    Boyink!

    5011 posts

    OK…you’ve lost me now with factors you didn’t mention earlier.

    Back to basics like eMan suggested - lose any htaccess stuff, the path variables, specify weblogs in the template, get more descriptive blog names, and get it all on one template in the most simplistic manner possible. 

    Then start adding the complexity in, step by step.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases