Channel Entry Tag Parameter replacement
Hi
I am trying to revamp some of my templates due to performance problems and one of these was to remove a couple of embeded templates.
I need to get the entry_date and expiration_date from one channel entry and pass these into another Channel entries tag as the start_on and stop_before parameters.
I have been trying everything that I know (which is not much) but I think the parse order is stopping me from doing this.
Is it possible to do this with Low Variables
Replies
Low 16 Jul 2012 22:16
You could probably achieve this by using a Textarea variable, adding the second channel:entries tag in it, ants using preparse params/vars to pass on the entry_date and expiration_date as the start_on and stop_before parameter values.
http://gotolow.com/addons/low-variabl...
ScottBoyde 16 Jul 2012 22:42
Just looking again an my first problem was I had {} around the low var name.
I think my secind issue us I have to two low variables one for start and one for end.
Any suggestions on the params needed for the preparse
This is my main channel entries
{exp:channel:entries
disable="category_fields|member_data"
category="{segment_3_category_id}"
channel="fixtures"
dynamic="no"
limit="30"
show_expired="no"
show_future_entries="yes"
orderby="date" sort="desc"
start_on="{exp:low_variables:single var='lv_snp_season_start_date'}"
status="open|Abandoned|Postponed|Late|Pending"
sticky="no"
stop_before="{exp:low_variables:single var='lv_snp_season_end_date'}"
paginate="bottom"
}
Low 17 Jul 2012 06:47
Using tags ({exp:anything:here}) as parameter input for other tags is never a good idea, since it's not consistent in its output.
Rather, I'd go with this:
In your template, put this:
And in the Low Variable "my_var", put this:
Like this, you're using the entry_date and expiration_date of the first entry as start_on and stop_before parameters for the second one.
ScottBoyde 17 Jul 2012 08:21
A bit of background
The site is a statistical one for football, I have a two channels that I use for cups and divisions that mark the season. These have the entry and expiry date fields filled in for the start and end dates of the season.
My main channel is the fixtures and this holds all the games for all divisions and cups.
They are linked together with categories.
My original fixtures template had a couple of embeds that where causing performance problems and now trying to fix that, but what I don't want is to make it worse.
The original template had the a channel entry for seasons and in that an embed for the fixtures, it passed in the entry date and expiry date for the latest season for that category.
So what I am really trying to achieve is getting that start and end date for that season and pass it into the start and end for my fixtures.
ScottBoyde 17 Jul 2012 08:22
I was also trying to use a sql query but this also didn't work unless I was just not using the right syntax for the low variable.
Low 17 Jul 2012 08:26
Sorry, I'm not quite following. You're saying my previously mentioned example will not work for you?
ScottBoyde 17 Jul 2012 08:57
Not sure whether I am doing this right or not. It appears to be working but not sure how.
With debugging on this is what gets parsed for the fixtures channel but no start_on or stop_before.
{exp:channel:entries channel="fixtures" disable="category_fields|member_data" category="16" dynamic="no" limit="30" show_expired="no" show_future_entries="yes" orderby="date" sort="desc" status="open|Abandoned|Postponed|Late|Pending" sticky="no" paginate="bottom" }
My fixtures template
{exp:channel:entries
channel="fixtures"
disable="category_fields|member_data"
category="{segment_3_category_id}"
dynamic="no"
limit="30"
show_expired="no"
show_future_entries="yes"
orderby="date" sort="desc"
status="open|Abandoned|Postponed|Late|Pending"
sticky="no"
paginate="bottom"
}
{exp:low_variables:single var="lv_snp_season_date" preparse:start_on="{entry_date}" preparse:stop_before="{expiration_date}"}
{/exp:channel:entries}
And my Low Variable "lv_snp_season_date"
{exp:channel:entries
channel="seasons"
disable="category_fields|member_data|pagination"
dynamic="no"
category="{segment_3_category_id}"
limit="1"
orderby="expiration_date"
show_expired="yes"
show_future_entries="yes"
sort="desc"
start_on="{start_on}"
stop_before="{stop_before}"
}
{/exp:channel:entries}
Low 17 Jul 2012 09:05
So, per single Season, you want to display all Fixtures that fall in that Season, right?
If that's the case (and taking a look at my example above), the first channel:entries tag should be the Season. The channel:entries tag in the LV should be the Fixtures. You can also add preparse:category="{segment_3_category_id}" to the LV tag, as that's an early parsed var that needs to be passed to the LV content.
That means your example should be reversed; Seasons in the Template, Fixtures in the LV.
ScottBoyde 17 Jul 2012 10:17
Apologies I don't think I am explaining this too well as well as not understanding.
You are correct I require to display all fixtures that fall in that season.
This is what I have below and not getting any fixtures displayed.
Template
{exp:channel:entries
channel="seasons"
disable="category_fields|member_data|pagination"
dynamic="no"
limit="1"
orderby="expiration_date"
show_expired="yes"
show_future_entries="yes"
sort="desc"
}
{exp:low_variables:single
var="lv_snp_season_date"
preparse:start_on="{entry_date}"
preparse:stop_before="{expiration_date}"
preparse:category="{segment_3_category_id}"}
{/exp:channel:entries}
Low Variable
{exp:channel:entries
channel="fixtures"
disable="category_fields|member_data"
category="{category}"
dynamic="no"
limit="30"
show_expired="no"
show_future_entries="yes"
orderby="date" sort="desc"
status="open|Abandoned|Postponed|Late|Pending"
sticky="no"
paginate="bottom"
start_on="{start_on}"
stop_before="{stop_before}"
}
...... Fixture Data Fields .....
{/exp:channel:entries}
Low 17 Jul 2012 11:54
I just saw that the start_on parameter requires a certain format.
Try this as the LV tag:
ScottBoyde 17 Jul 2012 11:57
Just realised that myself, testing this and thats a few times I have forgotten about that.
That's working great now thanks.
Would this approach be one you wouldn't recommend.
Low 17 Jul 2012 12:02
As long as the Seasons entries tag has a limit="1", you should be fine. Beats using an embed.
ScottBoyde 17 Jul 2012 12:18
That will only ever have one, hopefully.
Not sure whether you can help with this one or not ( I am also asking Brandon)
Within the Low Variable I have two other embeds
{exp:channel:entries channel="fixtures"
}
{embed="fixtures/.fixture_report" fixture="{entry_id}" team="{fixture_home_team}{entry_id}{/fixture_home_team}" }
{embed="fixtures/.fixture_report" fixture="{entry_id}" team="{fixture_home_team}{entry_id}{/fixture_home_team}" }
{/exp:channel:entries}
Embed
{exp:playa:parents channel="reports" entry_id="{embed:fixture}&&{embed:team}" }
<a href="{title_permalink='match-reports/comments'}/{embed:fixture}" title="Read match report">Report</a>
{if no_parents}
—
{/if}
{/exp:playa:parents}
These two embeds are checking each fixture to see if there is a report for it. And this is causing most of the performance problems.
Low 17 Jul 2012 15:44
Well, that will affect performance, yes. You're adding 2 embeds containing query-generating tags inside a tag that loops, generating more queries the more entries are displayed. I blogged about this two years ago.
You need to find a way to un-nest this. Perhaps by getting all reports beforehand, storing them in php and displaying them in the entries loop, similar to the approach I mention in the blog post.
ScottBoyde 17 Jul 2012 16:56
Thanks for the support and answers,
I think looking at the blog its well beyond my knowledge at the moment and will need to get someone to sort this for me.
ScottBoyde 17 Jul 2012 20:13
You aren't available for any freelance are you. : )
Low 18 Jul 2012 07:14
Sorry, I'm pretty much fully booked the coming months. :)