olivierbon / Placid

Placid is a Craft plugin which makes it easy to consume REST services in your twig templates
77 stars 5 forks source link

Placid in plugin #5

Closed a-am closed 9 years ago

a-am commented 9 years ago

Two questions. How do I check to see if Placid is available/installed? How do I make a Placid call from a plugin?

a-am commented 9 years ago

I figured part of it out.

craft()->placid_requests->getOptions($options)->request($handle);

alecritson commented 9 years ago

Okay glad you figured part of it out, to then test if the plugin is installed before you make that call you should be able to do something like:

$placid = craft()->plugins->getPlugin('placid');

if($placid)
{
  // Make the request
}

After reading the Craft docs, it would seem the proper way to utilise a plugin is through Hooks for example:

craft()->plugins->call('request', $options)

But I think you would run in to problems doing this with Placid as I haven't catered for other plugins to use it's internal workings. I will mark this as a feature request though and definitely consider adding this kind of usage :)