We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

“search:” parameter to constrain channel entries output by using a custom field (EE6) - question

How Do I?

Kami's avatar
Kami
8 posts
one month ago
Kami's avatar Kami

Hi,

I am trying to make sense of the “search:” parameter mentioned here :

https://docs.expressionengine.com/latest/channels/entries.html#searchfield_name

As shown on the two screenshots, I retrieve from the (url) query parameter the admin username.

I then try to filter the channel using the custom field and the custom field value.

{exp:channel:entries channel='Administrator' search:admin_user_name="{admin_user_name}” limit=”1”}

For some reasons, the same entry field values are always returned although the query parameter value changes.

Could you let me know if the only solution is to purchase the Low Search addon ?

Thanks.

K.

       
5BYFIVE Creative's avatar
5BYFIVE Creative
156 posts
one month ago
5BYFIVE Creative's avatar 5BYFIVE Creative

Can you confirm the variable is working ok? WIll {admin_user_name} output correctly? If yes, then maybe it is a parse order issue? maybe put the channel entries tag in an embed and pass the admin name through the embed.

       
jelle's avatar
jelle
46 posts
one month ago
jelle's avatar jelle

The search only happens in certain fields. Is the admin_user_name field a custom text field?. Also, you could try to do something like this: {exp:channel:entries channel='Administrator' search:admin_user_name="{segment_3}” limit=”1” dynamic=”no”}

       
Kami's avatar
Kami
8 posts
one month ago
Kami's avatar Kami

@5BYFIVE Creative : Thanks.

1) I confirm that {admin_username} outputs correctly, depending on the third segment of the url, i.e :

{preload_replace:admin_username="{segment_3}”} {layout='layouts2/_html_wrapper'} {if segment_4 } {redirect='404'} {/if} {admin_username} {!– the variable admin_username gives me the correct admin username depending on the url query parameter –}

2) I read EE6 documentation about embed and looked at all the examples I could find online. For the sake of it, I just tried :

{embed='admin/details' admin_user_name='{segment_3}’} {layout='layouts2/_html_wrapper'} {if segment_4 } {redirect='404'} {/if} {admin_username}

but as expected, this led to :

Error

You have caused a template loop due to improperly nested sub-templates (‘admin/details’ recursively called)

Template load order:

admin/details
admin/details
admin/details

@jelle

  • admin_user_name is a custom field . There is nothing (https://docs.expressionengine.com/latest/channels/entries.html#searchfield_name) suggesting that the “search:” parameter cannot be used with a custom field (I toggled the “Include in Search” option for that specific field).

I tried :

{layout='layouts2/_html_wrapper'} {if segment_4 } {redirect='404'} {/if} {exp:channel:entries channel='Administrator' search:admin_user_name="{segment_3}” limit=”1” dynamic=”no”} {admin_email_address} {!– the field admin_email_address always gives me the value adonovan@gmail.com no matter what {segment_3} is –} {/exp:channel:entries}

The same email address is outputted no matter what.

Do you have any other suggestions I could try ?

Thanks a lot.

K.

       
Kami's avatar
Kami
8 posts
one month ago
Kami's avatar Kami

Here are the 3 pieces of code in a more readable format :

https://www.codepile.net/pile/5Oaxkzda

Thanks.

K.

       
jelle's avatar
jelle
46 posts
one month ago
jelle's avatar jelle

that’s weird. might it be that {admin_email_address} is getting confused? what happens if you put {entry_id} in there? so like this:

{exp:channel:entries channel='Administrator' search:admin_user_name="{segment_3}” limit=”1” dynamic=”no”} 
{entry_id} 
{/exp:channel:entries}
       
Kami's avatar
Kami
8 posts
one month ago
Kami's avatar Kami

Hi,

your exact code generates what is in the screenshot to this reply.

Note that 24 is the newest entry id and 14 is the oldest entry id. (There are no other entry ids for this channel.)

This is extremely troubling.

Any other suggestions / workaround ?

Thanks.

K.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.