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.

more navigation help...linking to individual entries in a category

October 04, 2007 4:57am

Subscribe [3]
  • #1 / Oct 04, 2007 4:57am

    OffLead

    12 posts

    I’ve got most of this worked out, but am running into another problem with navigation. Here’s my template:

    {embed=layout/html_open}
    
    <div id="page">
      {embed=layout/header location="news"}
      <div id="main">
        <div id="content">
    
    {!-- show "news" or "important facts" teasers --}
    
          {if '{segment_3}' == 'C8' || '{segment_3}' == 'C10'}
    
            {exp:weblog:entries weblog="sec_news" sort="asc"}
              <h2>{title}<span class="date">  {entry_date format="%M %d, %Y - %h:%i %A"}</span></h2>
    <p>          {page_teaser} <a href="http://{title_permalink=" class="more">Full Story »</a>       <br />
            {/exp:weblog:entries}</p>
    
    <p>{!-- show "media kit" teasers --}</p>
    
    <p>      {if:elseif '{segment_3}' == 'C9'}</p>
    
    <p>        {exp:weblog:entries weblog="sec_news" sort="asc"}<br />
              </p><h2>{title}</h2>
    <p>          {page_teaser} <a href="http://{title_permalink=" class="more">Full Story »</a>       <br />
            {/exp:weblog:entries}</p>
    
    <p>{!-- show "newsletter" content --}</p>
    
    <p>      {if:elseif '{segment_3}' == 'C11'}</p>
    
    <p>        {exp:weblog:entries weblog="sec_news" sort="asc"}<br />
              </p><h2>{title}</h2>
    <p>          {page_body}     <br />
            {/exp:weblog:entries}<br />
          {/if}</p>
    
    <p>    </div><br />
        <div id="column"><br />
          <ul class="sectionnav"></p>
    
    <p>        {exp:weblog:categories weblog="sec_news" style="linear"}<br />
            <li><a href="http://{path=content/news}{category_url_title}" class="active">{category_name}</a></p>
    
    
    
    <p> </p>
    
    <p><br />
    {if '{category_id}' == '9' && '{segment_3}' == 'C9'}</p>
    
    <p>[[ NESTED LIST ITEMS GO HERE -- links to content items for category 9 ]]</p>
    
    <p>{/if}</p>
    
    <p> </p>
    
    <p> </p>
    
    <p><br />
            </li><br />
            {/exp:weblog:categories}<br />
     <br />
          </ul><br />
        </div><br />
      </div><br />
      {embed=layout/footer}<br />
    </div></p>
    
    <p>{embed=layout/html_close}


    The bit near the end (with the extra white-space so I can find it quicky) is where I’m stuck. The conditionals are working. Everything is displaying as it should, and where I have above indicated within square brackets that I want a nested list, test content I put in here does appear in my pages when I’m in the right category. Yay!

    What I can’t figure out here is the syntax for building the links to C9’s individual entries. Oh, and I’ll need to mark the appropriate entry link as active if that particular entry is loaded.

    I assume this is fairly simple, but I can’t seem to get it right after I figured out all the “hard” stuff.

  • #2 / Oct 04, 2007 2:03pm

    asozzi

    262 posts

    You mean something like this:

    <ul>
    {exp:weblog:entries weblog="sec_news" dynamic="off" category="9" limit="20" sort="asc" disable="trackbacks|member_data|pagination"}
                        <li><a href="http://{title_permalink=class=showing">{title}</a></li>    
                {/exp:weblog:entries}
    </ul>

    Where the current entry will have the class “showing” added.

  • #3 / Oct 04, 2007 2:16pm

    OffLead

    12 posts

    [asozzi, your reply came through while I was typing this up. Thanks!]

    Okay, I got some of this working. Some things came to me about 6am this morning as I drifted in and out of sleep. 😉

    I now have the page that displays the weblog (section) categories correctly. Here is this template again in its current incarnation:

    {embed=layout/html_open}
    
    <div id="page">
      {embed=layout/header location="news"}
      <div id="main">
        <div id="content">
    
    {!-- show "news" or "important facts" teasers --}
    
          {if '{segment_3}' == 'C8' || '{segment_3}' == 'C10'}
    
            {exp:weblog:entries weblog="sec_news" sort="asc"}
              <h2>{title}<span class="date">  {entry_date format="%M %d, %Y - %h:%i %A"}</span></h2>
    <p>          {page_teaser} <a href="http://{title_permalink=" class="more">Full Story »</a>       <br />
            {/exp:weblog:entries}</p>
    
    <p>{!-- show "media kit" teasers --}</p>
    
    <p>      {if:elseif '{segment_3}' == 'C9'}</p>
    
    <p>        {exp:weblog:entries weblog="sec_news" sort="asc"}<br />
              </p><h2>{title}</h2>
    <p>          {page_teaser} <a href="http://{title_permalink=" class="more">Full Story »</a>       <br />
            {/exp:weblog:entries}</p>
    
    <p>{!-- show "newsletter" content --}</p>
    
    <p>      {if:elseif '{segment_3}' == 'C11'}</p>
    
    <p>        {exp:weblog:entries weblog="sec_news" sort="asc"}<br />
              </p><h2>{title}</h2>
    <p>          {page_body}     <br />
            {/exp:weblog:entries}<br />
          {/if}</p>
    
    <p>    </div><br />
        <div id="column"><br />
          <ul class="sectionnav"></p>
    
    <p>        {exp:weblog:categories weblog="sec_news" style="linear" dynamic="off"}<br />
            <li><a href="http://{path=content/news}" class="active">{category_name}</a></p>
    
    
    
    <p> </p>
    
    <p><br />
    {if '{category_id}' == '9' && '{segment_3}' == 'C9'}</p>
    
    <p><ul><br />
            {exp:weblog:entries weblog="sec_news" dynamic="off" orderby="sort_order" sort="asc" category="9"}<br />
              <li><a href="http://{url_title_path=content/news_detail}" class="active">{title}</a></li><br />
             {/exp:weblog:entries}<br />
    </ul></p>
    
    <p>{/if}</p>
    
    <p> </p>
    
    <p> </p>
    
    <p><br />
            </li><br />
            {/exp:weblog:categories}</p>
    
    <p>      </ul><br />
        </div><br />
      </div><br />
      {embed=layout/footer}<br />
    </div></p>
    
    <p>{embed=layout/html_close}


    Now I need to get the view entry page working. It’s oh so close…haha. The functionality is actually there. The subnavigation does appear under the parent category link. What I can’t figure out is how to make it appear ONLY if you’re viewing an entry within that category. Here is the portion of the news_detail template that pertains to the navigation (again, extra space around the portion I’m currently working on):

    <div id="column">
          <ul class="sectionnav">
    
            {exp:weblog:categories weblog="sec_news" style="linear" dynamic="off"}
            <li><a href="http://{path=content/news}" class="active">{category_name}</a>
    
    
    
    
    
    
    {if '{category_id}' == '9'}
    <ul>
            {exp:weblog:entries weblog="sec_news" dynamic="off" orderby="sort_order" sort="asc" category="9"}
              <li><a href="http://{url_title_path=content/news_detail}" class="active">{title}</a></li>
             {/exp:weblog:entries}
    </ul>
    {/if}
    
    {if '{category_id}' == '8'}
    <ul>
            {exp:weblog:entries weblog="sec_news" dynamic="off" orderby="sort_order" sort="asc" category="8"}
              <li><a href="http://{url_title_path=content/news_detail}" class="active">{title}</a></li>
             {/exp:weblog:entries}
    </ul>
    {/if}
    
    
    
    
    
    
            </li>
            {/exp:weblog:categories}
     
          </ul>
        </div>


    What this gives me is a list like such (when viewing an entry):

    Category A
    —Entry A1
    —Entry A2
    —Entry A3
    Category B
    Category C
    —Entry C1
    —Entry C2
    —Entry C3
    Category D

    What I need it to do is show me ONLY the entry items for the category in which I’m viewing an entry. So if I’m viewing entry C2, the menu should look like this:

    Category A
    Category B
    Category C
    —Entry C1
    —Entry C2
    —Entry C3
    Category D

    And if I’m viewing entry A1, the menu should look like this:

    Category A
    —Entry A1
    —Entry A2
    —Entry A3
    Category B
    Category C
    Category D

    But since I’m in the single-entry template (news_detail in my case), the URL doesn’t have category data that I can use to check against like I was doing in the category-level template.

    I’m befuddled.

  • #4 / Oct 04, 2007 3:29pm

    OffLead

    12 posts

    Ahhh…I think I’ve found the answer. A small change to the news template in the area of the links to individual entries:

    <ul class="sectionnav">
    
            {exp:weblog:categories weblog="sec_news" style="linear" dynamic="off"}
            <li><a href="http://{path=content/news}" class="active">{category_name}</a>
    
    
    
    
    
    
    {if '{category_id}' == '9' && '{segment_3}' == 'C9'}
    <ul>
            {exp:weblog:entries weblog="sec_news" dynamic="off" orderby="sort_order" sort="asc" category="9"}
              <li><a href="http://{url_title_path=content/news_detail}{category_url_title}" class="active">{title}</a></li>
            {/exp:weblog:entries}
    </ul>
    {/if}
    
    
    
    
    
    
            </li>
            {/exp:weblog:categories}
    
          </ul>

     

    and the same navigation area from the news_detail template:

    <ul class="sectionnav">
    
            {exp:weblog:categories weblog="sec_news" style="linear" dynamic="off"}
            <li><a href="http://{path=content/news}" class="active">{category_name}</a>
    
    
    
    
    
    
    {if '{category_id}' == '9' && '{segment_4}' == '{category_url_title}'} 
    <ul>
            {exp:weblog:entries weblog="sec_news" dynamic="off" orderby="sort_order" sort="asc" category="9"}
              <li><a href="http://{url_title_path=content/news_detail}{category_url_title}" class="active">{title}</a></li>
            {/exp:weblog:entries}
    </ul>
    {/if}
    
    {if '{category_id}' == '8' && '{segment_4}' == '{category_url_title}'}
    <ul><li class="current">Story Detail</li></ul>
    {/if}
    
    {if '{category_id}' == '10' && '{segment_4}' == '{category_url_title}'}
    <ul><li class="current">Story Detail</li></ul>
    {/if}
    
    
    
    
    
    
            </li>
            {/exp:weblog:categories}
     
          </ul>


    This appears to be working as I intended, with (so far, knock wood) no unintended consequences. But if anyone sees any flaws in what I’m doing or can explain a cleaner way of doing it, I’d love to see it.

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

ExpressionEngine News!

#eecms, #events, #releases