How can I fire a controller action for a particular route or entry? 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' =&gt; array(
        'action' =&gt; 'micros/availability/search'
    )

);


And my plugin:

&lt;?php
namespace Craft;

class Micros_AvailabilityController extends BaseController
{

    protected $allowAnonymous = true;

    public function actionSearch()
    {
        Craft::dd('Micros_AvailabilityController-&gt;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.
It's more clear to me now that I've seen the database and extra description from the ticket.

The issue is that you've got an entry that already has has the URI of book.

Normally the code you're trying to use would work, but in resolving a route Craft matches any entry/category requests (Step 4) before it matches any dynamic routes (Step 5). 

When you're testing the action URL directly in the browser that works because it hits step 2.

One way to pull off what you're looking for is to give your plugin a template hook.  Then from the template that loads when book is hit, you can do something like:

{% if craft.request.getSegment(1) == 'book' %}
    {% hook "myAwesomeHook" %}
{% endif %}