Forum
Pass variables to collections
Is it possible to pass variables into collections?
I have set the variables:
PerchSystem::set_var('citySlug', 'sydney');
PerchSystem::set_var('daySlug', 'monday-1');
perch_collection('Programs', [
'template' => 'programs.html',
'category' => array('city/sydney', 'day/monday-1'),
'sort' => 'time',
'sort-order' => 'ASC',
]);
And referenced them in the template but they are not outputting:
<a class="button" href="/program/<perch:content id="citySlug" />/<perch:content id="daySlug" />/<perch:content id="slug" type="slug" for="title" />">Read more</a>
Any ideas how I can achieve this?
Yes, that should work fine. What does
<perch:showall />
show you?The variables were empty. Oddly enough changing the variable names to 'city_slug' as apposed to 'citySlug' made it work...
Do they appear in your edit form?
Drew, they don't now as I made them type="hidden". Maybe something happened and I saved them as empty values and changing the names reset them. Not sure, but everything is working now.