Hi,
I opened a topic recently describing how i was looking to replicate google’s “did you mean” function for my search results page. I’ve done this successfully by creating a plugin but am having one final issue with it..
I need to pass in the search term but it always seems to be passed through as blank. So far i’ve tried:
{exp:did_you_mean:search query="{exp:search:keywords}"}and:
<?php
$query = "{exp:search:keywords}";
?>
{exp:did_you_mean:search query="<?= $query ?>"}php is allowed for this template and i’ve tried both of these options with parsing stage set to both input and output. If i pass a normal string in my plugin works fine, i just can’t seem to get this to work with a variable?
Thanks, James Moved to Plugins by Moderator
Have you tried adding parse=”inward” to your plugin tag? I’ve never tried it when another EE tag is the parameter (rather than between a plugin tag pair) but it’s worse a shot. Another though, make an EE variable in your template of {exp:search:keywords} and use the variable in your plugin parameter instead of the EE tag itself.
Just some shots in the dark…
The only variable I’m finding that can be used as the value of a plugin parameter is a url segment. Are there any other types? The parse=”inward” parameter doesn’t seem to make any difference here.
Update: Oops, of course, a plugin can take variables from a weblog:entries tag and no doubt other main tags when wrapped within it. This solves my “problem”.
Similar problem in general I think: under what circumstances can you have a variable be the value of a plugin’s parameter? Seems most likely to work when it’s wrapped within a first-party tag.
For instance, while working on a plugin I see it won’t accept the {member_id} variable as a parameter, but the plugin will accept it if surrounded by the {exp:member:custom_profile_data} tag.
Similar problem in general I think: under what circumstances can you have a variable be the value of a plugin’s parameter?
I haven’t done enough testing or dove deep enough into the template parser core code to really answer that clearly and confidently. Obviously you’re going the right route with testing various methods. I tend to refer to this somewhat not-so-well-written wiki entry on Parsing Order when in doubt though.
Hi Guys,
I am having a really weird problem with this, i have tried wrapping my exp variable in the {exp:member:custom_profile_data} tag (although i am using the search results tag) and this seems to be cleared for some reason - even if i use php, create a variable and assign a string value, if i echo this out it works fine, but when i pass it in it seems to be cleared and is blank which is very strange. If i hard code a parameter into my template tag my plugin works fine but as soon as i try and pass my variable in it seems to clear it..
i’ll try a few more things when i get chance, not tried parse=”inward” yet but will let you know if it works!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.