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 template

July 15, 2007 3:13am

Subscribe [1]
  • #1 / Jul 15, 2007 3:13am

    Tiger0516

    31 posts

    Hi there,

    I am not a new user but :( suddenly (for somehow), I cannot understand the category template well (I used to know it well, I think)

    When I visit http://localhost/index.php/site/C1/ I can see all entries in this category. However, where is the template for category? The categories template come with EE seems to give a full list of all categories and entries for each category.

    Thanks

    😉

  • #2 / Jul 15, 2007 3:40am

    Lisa Wess

    20502 posts

    When you do that you’re leaving off “index”, making EE assume the “index” template. If you visit site/index/C1 you’ll see you get the same results. =)

  • #3 / Jul 15, 2007 4:09am

    Tiger0516

    31 posts

    Thanks.

    So http://localhost/index.php/site/C1/ is a shortcut to http://localhost/index.php/site/index/C1/ ?

    C1 seems to be a parameter. I had thought I need to use URL segment to get the category ID and pass this ID to weblog_archive to display entries.

    I still do not quite catch it: when visiting a category, how can I get all entries in this category? I just tell EE I am visiting this category (in URL) but I do not tell EE to display entries in this category (no such code in template)

  • #4 / Jul 15, 2007 4:28am

    Lisa Wess

    20502 posts

    Yes, if you skip the template name and put an EE recognized segment in there (category ID, url-title, etc) EE will assume the index.  Before the Pages module I used this to display entries at /info/about etc - where about was the url-title and info the template group, no template name.

    C1 isn’t a parameter, it’s a segment, but some segments EE handles automatically.  You do need to have that information in the segments for some operations but not all.  I don’t know what you mean by “weblog_archive” so I can’t answer that.  If you mean the category archives tag, that does not require a specific segment type.

    If you use the {exp:weblog:entries} tag without dynamic=“off” then EE will restrict to what is in the URL in segment_2 or segment_3.  If that is a url_title then it will show only a single entry and any comments/comment form you have shown.  If it’s a category ID then it will limit the list of entries by that category; or if you use category names, then if it’s the trigger word you chose.

    You don’t need the code in the template, it is a combination of the weblog entries code and your URI segments.

    So, put this into a template:

    {exp:weblog:entries limit="10"}
    {title}
    
    {/exp:weblog:entries}

    Now, visit it at just that template - it’ll show you the last 10 entries.  Append a category id like C1 and it will show the last 10 entries in category 1.  Append a url-title and it will show you only that entry.

    Make sense?

  • #5 / Jul 15, 2007 4:19pm

    Tiger0516

    31 posts

    Great!

    Thanks!

  • #6 / Jul 16, 2007 2:45am

    Tiger0516

    31 posts

    I have one more question 😊

    When visiting http://localhost/index.php/site/browse, I can get a list of all categories (main categories only)

    {exp:weblog:categories weblog="site" parent_only="yes"}
    {category_name}
    {/exp:weblog:categories}

    Now I want to click on each main category and see a list of all subcategories under this main category. What shall I do? I repeat code above (just remove parent_only=“yes”) and name it in a template named “sub”, but it does not work: it gives me a full list of all main categories and all subcategories.

    {exp:weblog:categories weblog="site"}
    {category_name}
    {/exp:weblog:categories}

    Thanks for help,

    😊

  • #7 / Jul 17, 2007 6:42pm

    Tiger0516

    31 posts

    bump up:)

  • #8 / Jul 17, 2007 6:45pm

    Lisa Wess

    20502 posts

    Hey =) This one is a bit more advanced, I’d recommend posting detailed question over in the how-to forum.  You might also search for the “subcategories” plugin or the “dynocat” plugin in our plugins forum.

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

ExpressionEngine News!

#eecms, #events, #releases