0

I know someone out there has done this before. I need to build a publications page that will show it's list of publications by a given year which has been filled in a channel field. I've googled I looked at the EE docs and I am not quite sure how to build this.

I have a channel field that will be filled with a 4 number year my content managers. Here is my basics. It of course lists all years in descending order but i need to make a separate page for "2015, 2014, 2013, etc."

Thanks for looking.

{exp:channel:entries 
   channel="publications" 
   orderby="pub_year"
   sort="desc"
   paginate="both"
   limit="8"
   }

          <h3 style="font-size: 1em; margin-bottom:3px;">{pub_year}</h3>

          <p><a href="{pub_year}">{title}.</a></p> 
         <!-- Etc. -->

{/exp:channel:entries}

2 Answers 2

0

If you could use the search parameter in conjunction with the url so you could access each year with something like

http://yoursite.com/template_group/year/2015

Then in your code you could do:

{exp:channel:entries 
   channel="publications" 
   orderby="pub_year"
   search:pub_year="={last_segment}"
   sort="desc"
   paginate="both"
   limit="8"
   }

          <h3 style="font-size: 1em; margin-bottom:3px;">{pub_year}</h3>

          <p><a href="{pub_year}">{title}.</a></p> 
         <!-- Etc. -->

{/exp:channel:entries}
2
  • I got no returns it doesn't seem to be seeing the last segment. I tried {if last_segment == '2014'}Last segment is 2014 {/if} to verify what was seen and it wouldn't return anything with search:pub_year="={last_segment}" but would on the regular last segment {if last_segment == 'year'} Last segment is year {/if}
    – Eric
    Commented Jan 25, 2015 at 5:02
  • I've stripped down to essentially what you have there no extraneous mark up, no js no css. it don't like the search:pub_year="={last_segment}" I've googled and looked at the docs seems like it should work. but no go.
    – Eric
    Commented Jan 25, 2015 at 18:01
0

Thanks for your help Johnathan, this put me on the right path. The final piece missing is (dynamic="no"). It appears it seems to think these are "id"s and is not returning the correct results. So the full answer is. Again Thanks!!

{exp:channel:entries 
   channel="publications" 
   orderby="pub_year"
   search:pub_year="={last_segment}"
   dynamic="no"
   sort="desc"
   limit="8"
   }

        <h3 style="font-size: 1em; margin-bottom:3px;">{pub_year}</h3>

        <p><a href="{pub_year}">{title}.</a></p> 
         <!-- Etc. -->

{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.