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.

Display most recent where custom field is not empty

October 10, 2007 4:28pm

Subscribe [1]
  • #1 / Oct 10, 2007 4:28pm

    tripp

    92 posts

    Can’t seem to get my head around this one…

    I need to display the title of only the most recent post where a custom field (video) contains a value. I understand that I need to drop in a conditional along these lines:

    {exp:weblog:entries weblog="news" [not sure what would go here]}
         {if video != ""}
              {title}
         {/if}
    {/exp:weblog:entries}

    ...but I don’t know how to write the exp:weblog:entries query. My attempts have either given me no results or way too many.


    ExpressionEngine 1.6.0
    Build:  20070918

  • #2 / Oct 10, 2007 4:33pm

    Lisa Wess

    20502 posts

    Do you need to also limit by the custom field, so only have entries where video is filled out? Or is it only the title that you need to conditionally show.  If the latter, then the weblog entries tag would just be your standard one with normal parameters for limit.

  • #3 / Oct 10, 2007 4:42pm

    tripp

    92 posts

    Do you need to also limit by the custom field, so only have entries where video is filled out?

    Yes, that’s what I’m trying to do.

    I need to display the title for only the most recent entry in the weblog where the video field contains data.

  • #4 / Oct 10, 2007 4:45pm

    Lisa Wess

    20502 posts

    If you need to show *only* entries that have that custom field filled out, then you’ll need an extension to do so, have a look in the Extensions forum for “Custom Fields in {exp:weblog:entries} by Mark Huot.

    If you use conditionals for this, you’ll still be processing those entries, you’re just hiding them from view.

  • #5 / Oct 10, 2007 5:04pm

    tripp

    92 posts

    The good news is that Mark’s extension is exactly what I need. The bad news is that using it involves modifying mod.weblog.php, which isn’t allowed on this particular project.

    Any other ideas?

  • #6 / Oct 10, 2007 5:14pm

    Lisa Wess

    20502 posts

    I’m going to have to move this to how-to at this point; but the only other options are a custom extension/plugin/module or query.  There are feature requests for this and you could add your voice; but if you need it immediately, then a custom query is your best bet.

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

ExpressionEngine News!

#eecms, #events, #releases