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.

select entry by custom field with segment_x

June 21, 2011 4:33pm

Subscribe [3]
  • #1 / Jun 21, 2011 4:33pm

    V.Gevers

    1 posts

    Hi,

    I made a custom field “foo” for channel “test” and I want to get that entry which has
    that value from {segment_2} (domein.ext/blah/[this.value]} and limit the results to one entry

    site/blah:

    {exp:channel:entries channel="test" limit="1" custom_fields="yes" search:foo="{segment_2}”}

    {title}
    {url_title}

    {/exp:channel:entries}

    When I hardcode search:foo=“this.value” then the correct entry is been shown. But not trough
    the segment_2 value. http://domein.ext/blah/this.value results in zero entries.
    Can I only query by title and url_title with channel module?

    Should I use the Query module instead? And how do I access the custom fields?

    Kind regards,
    Victor Gevers

  • #2 / Jun 21, 2011 6:44pm

    Matt:P

    277 posts

    Hi Victor

    I’m pretty sure custom_fields=“yes” only works if related_categories_mode=“yes” is used in the entries tag as well.

    Matt

  • #3 / Jun 22, 2011 5:32am

    John Henry Donovan

    12339 posts

    Victor ,

    You could also approach it this way

    {exp:channel:entries channel="test" dynamic="no"}
    
    {if foo == "{segment}"}
    {title}
    {url_title}
    {/if}
    
    {/exp:channel:entries}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases