custom plugin variable as exp:weblog:entries tag parameter
Posted: 29 January 2008 06:51 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

I am trying to use a variable from a plugin as a parameter inside an EE tag like so:

{exp:tscf:get_articles weblog_name="news"}
{exp
:weblog:entries weblog="news" limit="6" status="important|open" paginate="bottom" dynamic="on" category="{cat}"}
{
/exp:tscf:get_articles}

rest of exp
:weblog:entries stuff...

where {cat} is the variable being returned from the plugin.

This doesnt render the exp:weblog tags at all..

I looked at the thread here: http://expressionengine.com/forums/viewthread/33878/
What am I doing wrong?

Profile
 
 
Posted: 30 January 2008 03:51 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hiya vinci,

Don’t know if this will work or not but have you tried adding the parse=“inward” parameter to your plugin call as that can sometimes help. I tried doing something just like this a while back and must admit I never got it to work but this might in your case.

I was trying to simply send back a load of entry ids to the weblog entry_id parameter but could never get it to work though.

Hope this maybe works for you?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 30 January 2008 03:57 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

Hi Mark. I’ll try it out..
thanks for the assistance

Profile
 
 
Posted: 30 January 2008 04:17 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

No problem. I hope it works for you. If not then I’m sure one of the excellent admins around here can give a lending hand? wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 30 January 2008 04:41 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

Nope. That doesnt work.


In my plugin I have the following:

$tagdata = $TMPL->tagdata;
$tagdata = $TMPL->swap_var_single( 'cat', $embedded, $tagdata);
return
$tagdata;

In the template I have:

{exp:tscf:get_articles weblog_name="news" parse="inward”}
{cat}
{exp:weblog:entries weblog="
{blog}" limit="1" url_title="{segment_3}" status="open|important" category={cat}}
{/exp:tscf:get_articles}
{title}
{/exp:weblog:entries}

the first {cat} outputs the string correctly as: “45|66|77|23|1|56|90” (including the quotes)

After that the template outputs: {title} {/exp:weblog:entries}

Is there anyway to check if the second {cat} in the {exp:weblog:entries} tag is being processed?

Profile
 
 
Posted: 30 January 2008 04:50 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

Also just tried laying it up as:

{exp:tscf:get_articles weblog_name="news" parse="inward”}
{cat}
category={cat}
{exp:weblog:entries weblog="
{blog}" limit="1" url_title="{segment_3}" status="open|important" category={cat}}
{title}
{/exp:weblog:entries}
{/exp:tscf:get_articles}

The first {cat} prints fine, as: “13|15|29|16|30|17|24” including the quotes.
The second prints fine as well, as: category=“13|15|29|16|30|17|24”
The third inside the weblog tags doesnt, from what I can tell, because the {title} tag doesnt give me any titles, and I know there are entries in those categories.

Profile
 
 
Posted: 30 January 2008 04:58 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

hard coding the category = “13|15|29|16|30|17|24” in the exp:weblog:entries tag gives the correct results. so the plugin variable isnt being inserted there.

Profile
 
 
Posted: 30 January 2008 05:14 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

ok for some reason its now randomly working without touching anything. I think enclosing the custom plugin tags around the WHOLE exp:weblog tag pair may have helped.

Profile
 
 
Posted: 30 January 2008 11:23 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  750
Joined  08-16-2003

In your example above, you have:

{exp:weblog:entries weblog="{blog}" limit="1" url_title="{segment_3}" status="open|important" category={cat}}

You need:

{exp:weblog:entries weblog="{blog}" limit="1" url_title="{segment_3}" status="open|important" category="{cat}"}

See the added “quotes”?

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 30 January 2008 05:51 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

Thanks, but the quotes are included in the string that is returned by the plugin. i.e. 56|45|76|23|46|12 is actually output as “56|45|76|23|46|12” so it isnt a problem.

Besides, its working 100% now (although Im not sure what I did).
Thanks for all the help guys.

Profile
 
 
Posted: 30 January 2008 05:52 PM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hiya vinci,

Glad it’s all working for you now. Good luck with everything.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 30 January 2008 09:48 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

ok, i added a conditional inside the tag, and now its broke..

{exp:tscf:get_articles weblog_name="news" parse="inward"}

{exp
:weblog:entries weblog="news" limit="5" status="open|important" category={cat}}

{if no_results}
no results returned
{
/if}

<h2>{title}</h2>

{/exp:weblog:entries}
    
{
/exp:tscf:get_articles}


could someone tell me why this isnt working now?

Profile
 
 
Posted: 31 January 2008 08:55 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1330
Joined  02-12-2003

vinci,

Parse order is not your friend here.  And, sadly, using plugins to put values into entry tag parameters almost never works.  I’m not going to say never as I’ve seen strange cases where it does but its not something we can support.

It’s dirty but you can do what you need by setting PHP to parse on input and having PHP code in the template find the categories and insert them into the parameter before the entries tag is parsed by EE.

Jamie

Profile
 
 
Posted: 31 January 2008 09:02 PM   [ Ignore ]   [ # 13 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

euuuuch *shudders*

Profile
 
 
Posted: 03 February 2008 11:10 PM   [ Ignore ]   [ # 14 ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

its seems to be quite unstable. one method works, and then the next moment it doest.

I have manage to avoid php.. but at the end of the day I might as well have anyway, because the solution is still quite round-about.

This works for me, but im not saying it will work for anyone else.

the single variable wont be parsed in the exp:weblog tags, but I did manage to get it working to embed a template with a passed variable:

main template:


{exp:tscf:get_articles weblog_name="news" parse="inward"}

{embed
="news/news2" dog="{cat}"}

{
/exp:tscf:get_articles}


and then in a separate template (news2 in my case):

{embed:dog}
{exp
:weblog:entries weblog="news" limit="5" status="open|important" category="{embed:dog}"}
{if no_results}no results returned{
/if}
{title}
{
/exp:weblog:entries}


like I say, works for me, might need some experimenting though

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65030 Total Logged-in Users: 19
Total Topics: 82119 Total Anonymous Users: 10
Total Replies: 441329 Total Guests: 167
Total Posts: 523448    
Members ( View Memberlist )
Newest Members:  cfvicdreamNOIRgmonCooperWrightReedsmeenoiYang.JianuoioitsukiNathan Hammondalexcig