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.

List articles from current section

February 17, 2008 1:44pm

Subscribe [3]
  • #1 / Feb 17, 2008 1:44pm

    gdpfunding

    12 posts

    Hello,
    I have a sub navigation which is essentially just a list of articles.

    This is my code:

    <ul>
    {exp:query sql="SELECT blog_title, blog_name FROM exp_weblogs"}
    {exp:weblog:entries weblog="{blog_title}" dynamic="off"}
    <li><a href="http://{path=/bch/{url_title}}">{title}</a></li>
    {/exp:weblog:entries}
    {/exp:query}
    </ul>

    Unfortunately this lists EVERY article from EVERY section.  I would just like it to restrict the list to articles belonging to the same section as the current article.

    I hope that makes sense.

    Thanks

  • #2 / Feb 18, 2008 8:00am

    gdpfunding

    12 posts

    Sorry to nudge this but I still can’t find a solution :(

  • #3 / Feb 18, 2008 10:09am

    bnaut

    34 posts

    Someone recently suggested I try the related categories mode and it works fine for me, is this not what you are looking for?

  • #4 / Feb 18, 2008 1:02pm

    asozzi

    262 posts

    Assuming you mean: list all other articles from the categories the current article is in you can use:

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

    This actually does a lot more: since I used it in an embed:
    The weblog is passed manually but dynamically
    This is needed because dynamic=“off” needs to be set-> or you just list the current entry
    Also the current category needs to be passed—> A single article may belong to several categories, hence the single entry needs to be told which categorie(s) to list.
    Also the current article is highlighted in the list (class=showing).

    Hope this helps


    PS: if you’re ok with not listing the current article it’s easier to use the related articles mentioned above

  • #5 / Feb 18, 2008 3:53pm

    gdpfunding

    12 posts

    Im not using categories.  I need to show a list of articles belonging to the same weblog (section) as the the article currently being viewed.

  • #6 / Feb 18, 2008 4:15pm

    asozzi

    262 posts

    well then it’s even simpler, just leave out the

    category="cat"

    part.

    The key element is:

    dynamic="off"

    otherwise weblog:entries will dynamically reduce results according to the URL.

    Also, what is wrong with using related categories?


    Just set up a template and give it a try.

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

ExpressionEngine News!

#eecms, #events, #releases