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.

Dynamic menu w/categories: Show only parent entry

October 09, 2008 2:12pm

Subscribe [1]
  • #1 / Oct 09, 2008 2:12pm

    Jared Farrish

    575 posts

    This is driving me crazy.

    I am using the weblog:entries tag to display content from the URL based on the category or url_title found in the URL. The URL comes from the weblog:categories tag.

    Everything is fine for childless categories; I only get one entry displayed.

    However, for parent’s, I get the full shebang, all entries. I feel like parent_only=“yes” should be viable in the weblog:entries parameters, but of course it doesn’t seem to do anything.

    Here is the relevant template code:

    {exp:weblog:entries weblog="emergency_planning" dynamic="on" parent_only="yes"}
    {if no_results}
    <h3 class="page_title">404 Not Found</h3>
    The requested content was not found.
    {/if}
    {if category_request}
    {categories}
    {if "C{category_id}" == "{segment_3}"}
    <h1 class="page_title">{title}</h1>
    <h3 class="page_subheading">{article_subheading}</h3>
    {article_body}
    Posted on {entry_date format="%M %d, %Y - %h:%i %A"}
    {/categories}
    {/if}
    {if not_category_request}
    <h1 class="page_title">{title}</h1>
    <h3 class="page_subheading">{article_subheading}</h3>
    {article_body}
    Posted on {entry_date format="%M %d, %Y - %h:%i %A"}
    {/if}
    {/exp:weblog:entries}

    As you can probably tell, I have even tried testing for and limiting only the category in the URL itself, but that doesn’t work.

    If I set weblog:entries to limit=“1”, I get the first child entry content, but that’s not the right content.

    How do I get it to select only the parent category related entry?

    I am using EE 1.6.3.

    Thanks!
    Jared

  • #2 / Oct 09, 2008 2:44pm

    Jared Farrish

    575 posts

    Now I’m looking at the output, which is puzzling:

    if "C{category_id}" == "{segment_3}"

    And I see on each loop I get the parent in some case, plus the child, even though the only category_id I would expect would be for the entry provided in the loop:

    if "C20" == "C20" 
    
    ... entry C21 ...
    
    if "C21" == "C20"
    
    if "C20" == "C20"
    
    ... entry C23 ...
    
    if "C23" == "C20"
    
    if "C20" == "C20"
    
    ... entry C20 (this is all that should display) ...
    
    if "C20" == "C20" 
    
    ... entry C22 ...
    
    if "C22" == "C20" 
    
    (no entry)

    Am I going about this the wrong way? Why is it doing this? Why does it also loop over the parent before showing the entry, and validate the test when it should only be showing the category_id for that entry?

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

ExpressionEngine News!

#eecms, #events, #releases