So I have an entry that has some content displayed in a template.
However ahead of displaying that entry, I want a plugin's action to fire, which pulls some data in from a third party API that will display along with the entry content in the template.
The data from the plugin would need to be available in the template that gets loaded.
What's the best approach to do this?
Here's my routes.php file:
return array(
'book' => array(
'action' => 'micros/availability/search'
)
);
And my plugin:
<?php
namespace Craft;
class Micros_AvailabilityController extends BaseController
{
protected $allowAnonymous = true;
public function actionSearch()
{
Craft::dd('Micros_AvailabilityController->actionSearch()');
}
}
I have an Entry with a slug of 'book' and that loads a template from the templates directory, so what I'm seeing right now is that template, and I don't get the action method running at all.
What I want to do is do something in my action and attach the data to the request and return to whatever template the entry is using.
$this->renderTemplate('template/path', $variables);
– Brad Bell Mar 20 '15 at 18:54