I’m trying to create a private landing page for a photographer’s site. If a user is not logged in, they’re shown a login form. When they do log in, I want to show them a list of private galleries associated with their member ID (using LG Member List).
“customer” is my LG Member List custom field.
Snippet of initial code:
With this code, any logged in user sees the full listing of private galleries, for any member. Not ideal. This stuff:
custom_fields="on" member_data="on" customer="{logged_in_member_id}"in the weblog entries tag were just shots in the dark after not succeeding elsewhere.
The following works just fine on a specific private gallery page to restrict content to the member that should see it:
{if customer == logged_in_member_id}Any thoughts or suggestions would be greatly appreciated.
Note - I originally posted this in the wrong forum section. A workaround was posted there by Ingmar Greil. And while that works pretty well, it’s not nearly as intuitive for the client.
Hi Matt,
I might be wrong on this but from memory I’m pretty sure that the LG Member List extension exhibits a problem whereby it outputs the data stored in it surrounded by tags.
That could easily be tested by just outputting the value of that custom {customer} field in a template to see if it does indeed do that.
If it is indeed doing that then you should be able to fix the problem by following the tutorial located over at Devot-ee.com.
Hope that helps you get a little further on this one.
Best wishes,
Mark
Hey Mark - Thanks for the quick suggestion!
The {customer} field outputs the member_id of the member selected in from the LG Member List during the creation of a new entry. So that’s pretty much working as expected.
I checked out the Devot-ee tutorial, but I’m not sure that applies. My understanding of that tutorial is that it fixes issues associated with how the text gets formatted (or defaults to null when not specified, causing stuff to break). With LG Member List, however, text formatting isn’t available. It actually removes the option to choose format type (similar to a file or date field - see attached).
Just for the heck of it, I tried changing the entries call to use customer=”{customer}”, but that didn’t do anything either 😊
{exp:weblog:entries weblog="customers" dynamic="off" show_pages="no" custom_fields="on" member_data="on" customer="{customer}"}My thinking is the issue lies with not being able to filter results based on a custom field that isn’t a text input. Does that make sense? Does that give any new hints for a solution?
Hi Matt,
Did you actually try outputting just the field in a weblog entries tag and taking a look at the rendered source code?
Even though LG Member List doesn’t have any formatting options this is what from memory caused the problems in that the data if stored with NULL in the database will revert to a standard output of XHTML which places the tags around the field contents which from memory will cause the problem you are seeing.
I’d definitely suggest just placing a single weblog tag in a test template with just the custom field in there and nothing else. No markup, no css, nothing and seeing if the rendered source has tags surrounding it. If it does then you will definitely need to take a look at the Devot-ee.com article. If not then I’ll take another look for you.
Best wishes,
Mark
Gotcha. Thanks for the clarification.
I created a test template with this:
{exp:weblog:entries weblog="customers" dynamic="off" show_pages="no"}
{customer}
{/exp:weblog:entries}Its output was simply the member IDs of the two customers that were chosen in the posts with the LG Member List field:
8
2No other code was shown. Feel free to view the live page if it helps.
Ah right. Seems like you indeed don’t have the tag problem happening for you.
I’ve just noticed though (sorry didn’t see it before) that in your code above you are trying to do customer=”{customer}”. This can’t be done with either the custom field or with the logged_in_member_id. You can’t just include a custom field into your weblog tag as a parameter.
The only thing parameter that exists that you might possibly be able to use is the search://customer=”{customer}” parameter.
Don’t know if that helps at all in this instance though.
Ah yes. That’s what I was afraid of. The search: parameter doesn’t output anything for me. I thought perhaps by including the custom_fields=”on” parameter in the entries tag that would allow me to use my custom fields, but apparently not eh?
As I suspected, in the search:// parameter link you showed it says: “Only custom fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.” That means I can’t use the LG Member List field.
Suck an egg. Looks like the hack of changing the author of the entry to the member that should be able to view it, then using the author=”{member}” parameter is the way to go for now.
Thanks again for looking into it. Seems like it should be possible, but maybe not.
I got this working fine using the search parameter, though to get around parse order issues I had to pass the member_id using a url segment… though it would probably work with an embed too.
Here is my full code in case it helps anyone else:
{if logged_in && logged_in_member_id == '{segment_2}'}
{exp:weblog:entries weblog="resources" search:resources_member="={segment_2}" disable="member_data|pagination|trackbacks|categories" status="not closed" dynamic="off"}
{if no_results}
<h1>Your resources</h1>
<div class="highlight">Sorry! There is currently no personalised content associated with your account. Please <a href="http://{path=contact}">get in touch</a> if this is an unexpected problem.</div>
{/if}
{if title}<h1>{title}</h1>{/if}
{if resources_body}{resources_body}{/if}
{/exp:weblog:entries}
{if:else}
<h1>Access Denied</h1>
Sorry, you don't have permission to access this content. Please make sure you're logged in, or <a href="http://{path=contact}">get in touch</a> if this problem persists.
{/if}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.