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.

Content and Child/Parent Categories

November 19, 2007 11:15am

Subscribe [1]
  • #1 / Nov 19, 2007 11:15am

    dlw

    17 posts

    I wonder if anybody can tell me whether the following is possible:

    {if segment_2}
          {exp:weblog:category_heading weblog="{my_weblog}"}
          <h2>Library: {category_name}</h2>
    
    <p>        {exp:query sql="SELECT cat_id, cat_name, cat_url_title  FROM exp_categories WHERE parent_id = ' {category_id}' ORDER BY cat_order ASC"}<br />
              </p><h3>{cat_name}  {category_id}</h3>
    <p>          <ul id="category_list"><br />
              {exp:weblog:entries  weblog="{my_weblog}"  orderby="title" sort="asc"  category="{cat_id}"}<br />
              <li><a href="http://{file}">{title}</a></li><br />
              {/exp:weblog:entries}<br />
              </ul></p>
    
    <p>        {if no_results}<br />
              {exp:weblog:entries  weblog="{my_weblog}"  orderby="title" sort="asc"  category="{category_id}"}<br />
              <li><a href="http://">{title}</a></li><br />
              {/exp:weblog:entries}<br />
            {/if}</p>
    
    <p>        {/exp:query}</p>
    
    <p>      {/exp:weblog:category_heading}<br />
      {/if}

    I’m certain it isn’t as otherwise it would be working. I need to display entries irrespective of whether there is a child category or not. Any ideas would be appreciated.

    TIA,
    Daren

  • #2 / Jan 09, 2008 7:25am

    dlw

    17 posts

    I don’t want to bump a thread but I have found one work-around:

    {if segment_2}
          {exp:weblog:category_heading weblog="{my_weblog}"}
            <h2>Library: {category_name}</h2>
    
    <p>        {if category_name == "Handbook and Policies"} </p>
    
    <p>        {exp:query sql="SELECT cat_id, cat_name, cat_url_title  FROM exp_categories WHERE parent_id = ' {category_id}' ORDER BY cat_order ASC"}<br />
              </p><h3>{cat_name}</h3>
    <p>          <ul class="category_list"><br />
              {exp:weblog:entries  weblog="{my_weblog}"  orderby="title" sort="asc"  category="{cat_id}"}<br />
              <li><a href="http://{library_file}">{title}</a></li><br />
              {/exp:weblog:entries}<br />
              </ul><br />
            {/exp:query}   </p>
    
    <p>        {if:else} <br />
              <ul class="category_list"><br />
              {exp:weblog:entries  weblog="{my_weblog}"  orderby="title" sort="asc"  category="{category_id}"}<br />
              <li><a href="http://">{title}</a></li><br />
              {/exp:weblog:entries}<br />
              </ul><br />
            {/if} </p>
    
    <p>      {/exp:weblog:category_heading}<br />
      {/if}

    What I was hoping is that someone might have a more elegant solution. The problem with the above is that I will have to stop the client from being able to add categories. They probably wont need to anyway but it would be nice to allow that option.

    Thanks,
    Darren.

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

ExpressionEngine News!

#eecms, #events, #releases