Forum
Passing Variable into Blocks
Hi guys,
I've got some PHP code running to get some events:
$upcoming_events = perch_events_custom([
'filter'=>'eventDateTime',
'match' =>'gte',
'value' =>date("Y-m-d"),
'count' =>6,
'template'=>'/default/upcoming-event.html',
'skip-template'=>true
]);
PerchSystem::set_var('upcoming_events',$upcoming_events);
and I'm trying to call it into a Perch Block like this:
<perch:block type="upcoming-events" label="Upcoming Events">
<perch:help>
<p>This section will display the next six upcoming events, including events today.</p>
</perch:help>
<perch:content id="upcoming_events" />
</perch:block>
But nothing's coming up on the front end (apart from the print_r
command, obviously).
Also, the help doesn't show up inside the block, either. When adding the block, the dashboard view shows an empty, unlabelled text input, presumably the <perch:content id="upcoming_events" />
field.
Any ideas? Is this possible in Perch?
perch:events
tag in an events template.Hi Drew,
Thanks for the help here - almost there, I think!
So, the
events_custom( )
call is now working, and the variable is being set and passed through into the Block (inside thePage Content
region):Trouble is that I need to use the
/default/upcoming-event.html
template to render this data (which is why it's in theevents_custom( )
call, but the variable actually just displays the code that theevents_custom( )
call returns, rather than rendering it as HTML - any ideas?Thanks!
EDIT - Sorry, solved! I've added
encode="false"
to the variable call in thePage Content
region - thanks for the help on this, Drew!