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.

Searching for custom fields in entries

October 18, 2010 4:13pm

Subscribe [4]
  • #1 / Oct 18, 2010 4:13pm

    ramonekalsaw

    377 posts

    Hello,

    I need to search all of my entries and find those which have content in a specific custom field I set up. To do this, do I need to create a query? And if so, can you give me an idea of how that query would be structured?

    Thanks.

  • #2 / Oct 18, 2010 4:18pm

    Ingmar

    29245 posts

    Take a look at the search parameter.

  • #3 / Oct 18, 2010 6:12pm

    ramonekalsaw

    377 posts

    Take a look at the search parameter.

    Ok ... I have the syntax

    search:body="not IS_EMPTY"
    This example would return all results where the body field is not empty, i.e. only entries where the body field had content.

    ... now how to apply it ...

    I’m updating a live site and need to generate a list that includes all of the search results, like would happen in the Edit screen of the control panel. My reading of the doc implies that I would include search:body=“not IS_EMPTY” as part of {exp:weblog:entries}, but I don’t want the template to render this list, I want this list for my own use so I can open these entries and edit them.

    So is search: the way to go about this, and if so, how do I use it to generate the list?

    Thanks.

  • #4 / Oct 19, 2010 7:31am

    Sue Crocker

    26054 posts

    What I’d do is create a template group that has restricted access, just for SuperAdmins. If anyone else gets there, set the template to go to the main template or something similar. Then build an Edit This link inside your links.

    See: http://eehowto.com/howto/articles/howto-add-an-edit-this-link-in-ee2

  • #5 / Oct 19, 2010 2:31pm

    ramonekalsaw

    377 posts

    What I’d do is create a template group that has restricted access, just for SuperAdmins. If anyone else gets there, set the template to go to the main template or something similar. Then build an Edit This link inside your links.

    See: http://eehowto.com/howto/articles/howto-add-an-edit-this-link-in-ee2

    It seems to me that searching for—my_field=“not IS_EMPTY”—would be the most direct approach to generating the list I need. Isn’t there a way to simply search/query for all entries that fit this criteria?

    In the past I used the following query to list the names in my mailing list. Couldn’t I do something similar to list all articles where: my_field=“not IS_EMPTY”?

    {exp:query sql="select email from exp_mailing_list where list_id = '16' order by email asc"}
    {email}
    
    {/exp:query}

    Thanks.

  • #6 / Oct 19, 2010 4:16pm

    Ingmar

    29245 posts

    Yes, of course, and SQL query is always an option. Something like

    SELECT * FROM exp_channel_data WHERE field_id_1 != ""
  • #7 / Oct 21, 2010 10:42pm

    ramonekalsaw

    377 posts

    I’m using the following search code and it’s generating a list of articles that are displaying horizontally. What do I need to do to get them to list vertically, one to a line?

    Thanks

    {exp:weblog:entries weblog="teahouse" 
    search:extended!="IS_EMPTY"}
    {title}
    {/exp:weblog:entries}

    This is how the search is being returned:

    Tassajara Journey: A Late Summer Retreat Winter Solstice Retreat: Following Your Energy Inward Seasonal Chi Kung at BIOM: The Ba Gua Form Staying Healthy In Autumn Recognizing and Managing Stress Chi and Oriental Medicine Food Rules: An Eater’s Manual by Michael Pollan Preventing Illness With a Strong Immune System Summer Solstice: Being in Rhythm With

  • #8 / Oct 21, 2010 10:58pm

    ramonekalsaw

    377 posts

    Also ... Is there something wrong with this code? I’m trying to get a list of entries where the “extended” field is NOT EMPTY, but it looks like the list being generated includes all entries.

    {exp:weblog:entries weblog="teahouse" 
    search:extended!="IS_EMPTY"}
    {title}
    {/exp:weblog:entries}

    Thanks.

  • #9 / Oct 22, 2010 10:40am

    Ingmar

    29245 posts

    I’m using the following search code and it’s generating a list of articles that are displaying horizontally. What do I need to do to get them to list vertically, one to a line?

    You’ll add some markup the way you always do in a channel:entries loop, like so:

    {exp:weblog:entries weblog="teahouse" 
    search:extended="not IS_EMPTY"}
    {title}
    
    {/exp:weblog:entries}

    or even:

    <ul>{exp:weblog:entries weblog="teahouse" 
    search:extended="not IS_EMPTY"}
    <li>{title}</li>
    {/exp:weblog:entries}
    </ul>

    Also mind the correct syntax, search:extended=“not IS_EMPTY”.

  • #10 / Oct 22, 2010 7:19pm

    ramonekalsaw

    377 posts

    Thanks, Ingmar! Just what I needed : )

  • #11 / Oct 22, 2010 7:27pm

    Sue Crocker

    26054 posts

    Glad Ingmar was able to help. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases