A simple plugin interface with YouTube for October CMS.
- Clone or download the repo into
plugins/bluhex/youtube
. - Run
composer update
to get the latest google client.
API Key
: YouTube API key is needed to access the API.Minutes cached
: Time in minutes that the results should be cached for
- Head on over to https://console.developers.google.com/project and either select your existing project or create a new one.
- Under "APIs" enable "YouTube data API v3"
- Go to Credentials and under "Public API access" select "Create a new key"
- Copy the new API Key into the settings and save.
Use the Latest Videos
component to display a list of the latest videos for a channel. The component has the following properties available for config:
-
channel_id
: The YouTube channel id can be found over at https://www.youtube.com/account_advanced. -
max_items
: Maximum number of videos to display, at this time there is no pagination support.
Under the CMS > Partials
menu, create a new partial called latestVideos/default.htm
.
Inside the videos array each video object contains the following:
link
: URL of the videotitle
: Video titlethumbnail
: URL of the maximum resolution version of the thumbnaildescription
: Excerpt of the video descriptionpublished_at
: Carbon date of the publish date
{% set videos = __SELF__.videos %}
{% for video in videos %}
<a href="{{ video.link }}">
<img src="{{ video.thumbnail }}" alt="{{ video.title }}">
<span>{{ video.title }}</span>
</a>
{% endfor %}