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.

Possible to add custom field in weblog entries tag?

January 30, 2012 9:32pm

Subscribe [3]
  • #1 / Jan 30, 2012 9:32pm

    temada

    9 posts

    I’m not sure if this can be done, or if I’m somehow complicating matters.

    I’m trying to use just one template, for one weblog, but only show posts based on a specified category. Trouble is, I’d like the category number to change with a custom field called “category-number”. But it doesn’t seem to work if I add a custom field to the weblog tag. I’m using EE 1.7.1.

    For instance, this works:

    {exp:weblog:entries weblog="courses" orderby="date" sort="desc" limit="1" disable="member_data|trackbacks" category="12" dynamic="yes"}
    {body-courses}
    {extended}
    {/exp:weblog:entries}

    This does not work:

    {exp:weblog:entries weblog="courses" orderby="date" sort="desc" limit="1" disable="member_data|trackbacks" category="{category-number}” dynamic=“yes”}
    {body-courses}
    {extended}
    {/exp:weblog:entries}

    I’ve tried turning off dynamic, but that did not change anything. So does that mean I can’t use a custom field in the weblog entries tag? Is there another way to do this?

    To reiterate, my goal is to use just one template for a weblog, but be able to show only posts associated with a specific category, which I assume I need to assign in the post itself. So the category needs to be able to change, but still display in the one template.

  • #2 / Jan 30, 2012 11:19pm

    Boyink!

    5011 posts

    No, you can’t use custom fields because it’s too early in the parsing process.  The custom field is only available in the tag results, after the opening tag.

    Any particular reason to not use native categories and the related dynamic nature of the weblog:entries tag to create a reusable category template?

  • #3 / Jan 30, 2012 11:25pm

    temada

    9 posts

    Thanks for the reply.

    I’m not an expert at EE (even the legacy version), so I’m not sure what you mean by this:

    “...native categories and the related dynamic nature of the weblog:entries tag to create a reusable category template?”

    Can you provide an example? A reusable category template would be a real time saver.

  • #4 / Jan 30, 2012 11:29pm

    Boyink!

    5011 posts

    Sure…start here:

    http://www.train-ee.com/courseware/free-tutorials/comments/13-implementing-the-weblog-index-template/

    It’s a tutorial series I wrote for EE1 that covers the building of a weblog index template that is re-used for a category template.

  • #5 / Jan 30, 2012 11:35pm

    temada

    9 posts

    Thank you very much.

    I appreciate the time you’ve taken to reply, and for all the work on the tutorial. I’ll read it through and get this figured out.

    EE forum support is just one of the reasons I stick with EE when it seems everyone is pressuring for Wordpress.

  • #6 / Jan 30, 2012 11:47pm

    Boyink!

    5011 posts

    Cheers!

  • #7 / Feb 01, 2012 12:20pm

    Kyle Cotter

    730 posts

    Hey temada,

    Glad Mike and his tutorials are of value here!

    I’m going to mark this as closed, but if you do find yourself still having issues, just click on “create related issue” at the top of this thread.

    Thanks guys!

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

ExpressionEngine News!

#eecms, #events, #releases