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.

Will an entry show if the custom field queried by a channel entries search parameter does not exist?

March 08, 2012 1:50am

Subscribe [1]
  • #1 / Mar 08, 2012 1:50am

    Hello there,

    I’m getting back some odd results in my test install so wanted to ask you for some advice.

    The Setup
    I’ve got 2 channels, “blog” and “case_studies” (these are the channel names), they both use different custom field groups.

    What I need to get out of this loop.
    I need to create a loop where ALL posts from blog show up AND only those posts from case_studies that match the search:case_study_field=“not IS_EMPTY” parameter.

    The Problem
    The case_study_field however does not exist at all in the blog entries since those are using a different custom field group.

    The Question
    So what happens (and what is supposed to happen) when I use a search param and query a field that only exists in some of the pulled entries?

    Here is my loop at the moment:

    {exp:channel:entries
     channel="blog|case_studies"
     disable="category_fields|member_data"
     require_entry="yes"
     dynamic="no"
     limit="5"
     search:case_study_field="not IS_EMPTY"
    }

    Thanks for reading,
    look forward to your reply.

    Jannis

    PS: Using EE 2.4.0 build 20120123

  • #2 / Mar 08, 2012 7:34pm

    Sean C. Smith

    3818 posts

    Hi Jannis Gundermann,

    Unfortunately what you are trying to do is not possible with ExpressionEngine. I also can’t think of a work around to achieve what you are trying to do.

    Sean

  • #3 / Mar 08, 2012 7:40pm

    Hey Sean,

    thanks for your reply.

    Can you think of any other way (even if that means i have to redo a bunch of admin stuff like custom field groups or channels) of basically segregating case studies into their own channel but giving the end user the possibility of ‘promoting’ a case study to show up alongside the blog entries?

    Maybe something category driven?

    Creating a cat group with a single checkbox for “Promote to blog feed” then if checked push case studies into the blog feed? The blog entries could share this checkbox and have it ticked by default or something (can you set a default category per channel?)…

    Any ideas would be much appreciated.

    Thanks,
    Jannis

  • #4 / Mar 09, 2012 5:49pm

    Sean C. Smith

    3818 posts

    Hi Jannis,

    Keeping the case studies and blog channels separate I would suggest setting up statuses. For case studies you would add a status of “promoted” and then only case studies that are “promoted” would show up. You would also need to set a new status for blog entries which could be anything, say “published” because if you use Open then all case_studies with an open status would also show up.

    Inside your channel entries add the paramenter status=“published|promoted” and you will now get both the blog and only the case studies that have been promoted.

    Does that help?

    Sean

  • #5 / Mar 09, 2012 5:56pm

    Hey Sean,

    that’s great! I see how that could work quite well actually, thanks for the advice.

    Do you think the category/checkbox driven approach would also work or are there any obvious mistakes in my logic or performance issues that I didn’t consider?

    The reason I ask is because for the author/editor publishing articles it would be a nicer user experience to check a box that promotes things as opposed to selecting from various options inside a status dropdown which would likely contain 4 at this stage; “Hide”, “For Review”, “Show in Case Studies”, “Show in Case Studies and Blog”.

    Kindest regards,
    Jannis

  • #6 / Mar 09, 2012 8:12pm

    Sean C. Smith

    3818 posts

    Jannis,

    You could use categories as an alternative, but if you do so then you would need to include all categories from the blog as well as the single category from the case studies in order to get it to work the way you want. categories=“1|2|3|4|5|12” where categories 1 through 5 are from the blog and category 12 is for case studies to be promoted.

    Does that make sense?

    Sean

  • #7 / Mar 09, 2012 8:15pm

    Gotcha, thanks for the quick response.

    I think your initial status focussed approach maybe cleaner in the long run, I will go for that one but thank you for elaborating on the category approach, makes sense to me.

    Thanks Sean,
    Jannis

  • #8 / Mar 11, 2012 1:41pm

    Sean C. Smith

    3818 posts

    Jannis,

    Glad I could help. I’m going to close out this thread, but feel free to post again when you have more questions.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases