Parsing Issue
Posted: 03 November 2009 09:29 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  107
Joined  03-09-2009

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

Profile
 
 
Posted: 03 November 2009 09:48 AM   [ Ignore ]   [ # 1 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  30388
Joined  04-29-2002

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

Profile
MSG
 
 
Posted: 10 November 2009 01:33 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  107
Joined  03-09-2009

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

Profile
 
 
Posted: 28 November 2009 11:12 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1182
Joined  03-24-2009

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…

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

Profile
 
 
Posted: 29 November 2009 09:35 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  463
Joined  12-20-2002

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

 Signature 

Who ain’t a slave? - Ishmael

Profile
 
 
Posted: 29 November 2009 11:59 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1182
Joined  03-24-2009
Adam Khan - 30 November 2009 02:35 AM

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?

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

Profile
 
 
Posted: 30 November 2009 12:07 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  463
Joined  12-20-2002

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.

 Signature 

Who ain’t a slave? - Ishmael

Profile
 
 
Posted: 30 November 2009 12:15 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1182
Joined  03-24-2009
Adam Khan - 30 November 2009 05:07 AM

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.

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

Profile
 
 
Posted: 30 November 2009 05:22 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  107
Joined  03-09-2009

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!

Profile