Forum
Returning custom content from another page matched by user entered content
I have a list of venues that I want to return 'suites' that are associated with the venue page a user is currently on. Both pages have a region which sets the location a suite should be associated with.
perch_content_custom('suite excerpt content', array(
'page'=>'/suites/*',
'template'=>'venue-templates/venue_suites_listing.html',
'filter'=>'location',
'match'=>'eq',
'value'=> $locationName
));
So $locationName would need to be the location already entered by the admin for that page. i.e London which then checks if it matches whats been entered in the suite excerpt content region and then obviously shows all suites associated with that venue. I'm not sure how I set $locationName as perch_content('location') that the admin has entered though. I tried using perch_content('location',true) as I thought this would return the value entered but that doesn't work.
Can anyone help?
That should work
provided that the region just returns the string you're wanting to filter by.
If that doesn't work, turn on debug and let us know what it outputs, and in what way it's not working.
It just seems to be returning an empty string. No errors. If I do a <perch: showall /> and hardcode the 'value' to one thats there I can see the value being returned.
What does this output?
I've made some progress. "location" region wasn't outputting anything so I assumed it was somethign to do with my select box template. I updated it and copied it exactly from perch docs and that has at least started outputting some content. I can't see what the difference between my 2 templates though so I'm assuming it was some kind of white-space issue.
Now it is outputting the location name but has break line characters in it, is this because it's coming from a select?
Do those appear in the HTML source of the select box?
No doesn't show in the source
I've just recreated the select boxes again and seems to of resolved the issue this time. I'm not 100% sure what has actually solved the problem but I can only assume the way I'd entered the select options before created some white space within the values some how.
I did some testing copying the code from perch docs select box examples and they weren't outputting any additional characters.