Client Login.

Justin Long // ExpressionEngine Expert

ExpressionEngine Search Parameter Woes

Written by: Justin Long | On: January 13, 2011

For a project that I am working on I have a channel that use VZ Member to link a site member to a channel entry. VZ Member is a simple fieldtype that simply stores the member id of the selected members or in my case member. In my template I was going to use the search tag to allow logged in users to view/edit their weblog entry. So I started with the following template code:
{exp:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={member_id}"
Which parsed absolutely nothing. Turned on debugging and nothing looked out of the ordinary so I moved on to another approach. I remembered that member_id was not available inside of the channel entries loop because it was already parsing member data associated with the entry but I should be able to use logged_in_member_id so with renewed vigor I changed my template code to:
{exp:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={logged_in_member_id}"
Refresh my page and still nothing. Maybe the global variable is not parsing because of the parsing order so lets move it out of the loop by putting it in a variable. Which resulted in the following template code
:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={mem_id}"
Still no luck so lets tweak it a little.
:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={mem_id}"
Alas we are going no where so lets move my channel entries loop into an embed.
<!-- Main Template -->
{embed="embeds/.member_link" mem_id="{member_id}"}
<!-- Embed Template -->
{exp:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={embed:mem_id}"
As I am sure you are guessing this is still not working so lets create a snippet and try that.
<!-- Snippet File -->
<!-- main Template -->
{exp:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={my_snippet}"
So by this point I am pulling my hair out and venting to everyone on Twitter because this should be working. At this point @adamrotman sends me a message on Skype with a few suggestions that I can try. Which brings me to the actual template code that I got to work which uses the exp:member_custom_profile_data to grab information from the member database tables like I needed. I still needed to use an embed to deal with the parsing issues but it is working as it needs to.
<!-- Main Template -->
{embed="embeds/.member_link" mem_id="{exp:member:custom_profile_data}{member_id}{/exp:member:custom_profile_data}"}
<!-- Embed Template -->
{exp:channel:entries channel="member_link" limit="1" dynamic="no" search:vz_member_field="={embed:mem_id}"
This allows me to have a clean url but show the entries that are linked to a particular user all from the same URL. They can then edit them as they need to.

I hope this helps and as always if you have any questions or thoughts post them in the comments below.

Next entry >>> <<< Previous entry


<<< Go back to entry list