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

ExpressionEngine Logo ExpressionEngine
Features Pricing 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

Parsing Issue

Development and Programming

jamesa's avatar
jamesa
75 posts
16 years ago
jamesa's avatar jamesa

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

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Hi, James. We don’t provide direct support for writing your own plugins, moving this to the Plugins folder for additional community support.

       
jamesa's avatar
jamesa
75 posts
16 years ago
jamesa's avatar jamesa

Hi,

Has anyone got any ideas how to fix this? - i’ve run out and still can’t seem to get this working..

thanks in advance,

James

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
16 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

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…

       
Adam Khan's avatar
Adam Khan
319 posts
16 years ago
Adam Khan's avatar Adam Khan

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”.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
16 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
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”.

Is this the same problem that James was experiencing above or something separate?

       
Adam Khan's avatar
Adam Khan
319 posts
16 years ago
Adam Khan's avatar Adam Khan

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.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
16 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
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.

       
jamesa's avatar
jamesa
75 posts
16 years ago
jamesa's avatar jamesa

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!

       

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.