Hi all. I have a bit of php code that is called by a js script to get a json encoded list of calendar events from Solspace Calendar (the date comes in as segment_3 without issue:
What I’m doing here is trying to assemble a link to each event, but the structure of the link is kind of difficult. It has to be “schedule/[show url_title]/[event date].
Basically, I have a calendar of many different events, each of which has a show (it is a radio website), selected with a Playa fieldtype. When looking at the schedule, it will list the show name, but my client wants it to link to the actual entry on that date, not the show landing page. You can see I’m trying to build the url with a series of $url building lines, but only because I’ve deconstructed it to the basics. In the output, the $url is printing out just fine, but the order of the processing is making this an issue. The embed is running after the php, so I can’t get that second portion of the url in there. Make sense? What are my options? Thanks!
<? /* THIS TEMPLATE IS USED BY THE HOMEPAGE TO SHOW A LIST OF SHOWS FOR A GIVEN DAY */
$o->shows = array();
$id = 0;
?>
{exp:calendar:cal date_range_start="{segment_3}" show_days="1" pad_short_weeks="n" }
<?
$url = "/schedule/";
$url .= '{embed="snippets/get_show_name_by_event" event-url-title="{event_url_title}"}/';
$url .= '{event_start_date format="%Y-%m-%d"}';
echo $url;
$o->shows[$id]->show->title = '{event_title}';
$o->shows[$id]->show->date = '{event_start_date format="%h:%i%A"}';
$o->shows[$id]->show->link = $url;
$id++;
?>
{/exp:calendar:cal}
<?= json_encode($o); ?>where my embed “snippets/get_show_name_by_event” is:
{exp:calendar:events event_name="{embed:event-url-title}"}
{schedule_show}{url_title}{/schedule_show}
{/exp:calendar:events}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.