Skip to content

a-am/Placid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

README

Placid is a Craft plugin which makes it easy to use REST services in your twig templates, whether thats getting a twitter feed, showing off dribbble shots or getting the weather, Placid has you covered.

Scrutinizer Code Quality

Installing / Updating

Installing

Updating

Whats new in 1.2.5

  • You can now make requests via AJAX
  • There is an onBeforeRequest Event
  • There is an onAfterRequest Event
  • You can now specify the cache duration using the duration config in your template
  • The way Placid works has been rewritten for better compatibility with Guzzle
  • There is a new tag, craft.placid.request(handle) (does the same as .get() but will be more futureproof)
  • You can now set the method of the request (templates only right now)
  • Failed requests are handled gracefully and don't stop templates loading

Changes in 1.2.5

  • Segments defined in the template will now override the segments set in the admin area

Basic template example

This example assumes you have a twitter request set up and authenticated using OAuth, for other examples see here

craft.placid.request(requestHandle)
This is the main placid variable, use this to get the data from the request.

{% set timeline = craft.placid.request('twitterFeed') %}
{% for tweet in timeline %}
  {{ tweet.text }}
{% endfor %}

Template parameters

  • cache (bool) - Whether or not to cache the request, default is true
  • duration (number) - The length of time in seconds to cache the request, default is whatever is in your default config
  • query (array) - An array of key/value pairs to set in the query string
  • method (string) - What method to use for the request, default is GET
  • segments (string) - The segments to use in the request, overrides any set in admin

For full instructions on how to use, refer to docs

About

Placid is a Craft plugin which makes it easy to consume REST services in your twig templates

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 53.7%
  • PHP 33.0%
  • HTML 12.2%
  • CSS 1.1%