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.

How to Show Month Links for a Specific Category?

January 03, 2011 10:13pm

Subscribe [5]
  • #1 / Jan 03, 2011 10:13pm

    msmith29063

    75 posts

    I’m using the following snippet to create a pulldown menu for selecting a monthly archive:

    <select class="form" name="Month">
    {exp:channel:month_links channel="news"}
    <option value="{path='channel/newsarchive'}"{if segment_3 == year AND segment_4 == month_num} selected{/if}>{month} {year}</option>
    {/exp:channel:month_links}
    </select>

    The issue is that month_links doesn’t allow me to select a specific category ID—which is what I need. Any ways around this?

    Thank you for your help!

  • #2 / Jan 04, 2011 4:05pm

    Ingmar

    29245 posts

    I am afraid you might need a custom SQL query here. Let me move this thread to the CSS corner for you for some additional community support.

  • #3 / Jan 16, 2012 7:02am

    Fingo

    9 posts

    I really need this functionality.

    Any pointers or code snippet for the SQL query?

  • #4 / Oct 26, 2012 7:50pm

    Let’s bump this up! I’m looking for exact same thing, adding category=”” to Archive Month tag, but in 1.x version.
    Subscribed.

  • #5 / Oct 28, 2012 2:47pm

    ahmad saad

    364 posts

    there is a simple workaround for this issuse by using channel:entries like this:

    {exp:channel:entries channel="news" category="{put your category id}" }
    {date_heading display="monthly"}
    }
    <option value="{path='channel/newsarchive/{entry_date format="%Y"}/{entry_date format="%m"}'}"{if segment_3 == {entry_date format="%Y"} AND segment_4 == {entry_date format="%m"}} selected{/if}>{entry_date format="%F %Y"}</option>
     {/date_heading}
    {/exp:channel:entries}

    I think this will work for u, tell me if this work.

     

  • #6 / Oct 28, 2012 5:22pm

    I thought of this solution, too. I can see what you’re doing here instead of using the archive month tags. It should work. I’ll try it and let you know…

  • #7 / Oct 30, 2012 5:46pm

    FYI, this worked out perfectly. If you’re using this in a sidebar don’t forget to disable the dynamic parameter in the exp:channel:entries tag. On the actual monthly archives page make sure to add the category tag to the main exp:channel:entries tag listing all the articles down the page. This works beautifully with multiple channels as well. I’m using it in a 1.x build so here’s the code for the sidebar using regular links instead of a drop-down menu + the monthly archives landing page.

    http://pastie.org/5139715

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

ExpressionEngine News!

#eecms, #events, #releases