Youtube Gallery Plugin for CMSimple

IntroductionBack to top

This plugin is designed to simplify the creation, management and frontend presentation of youtube video galleries. The backend allows the creation of different galleries, adding videos just with their youtube id, title, description and the position in the gallery.

Youtube frontend preview.

Consider donating to support this plugin.

VersionBack to top

This is currently version 1.3.2 of the plugin, released January 6th 2018.

RequiremeqntsBack to top

PHPBack to top

Update: A CSV helper is used. The helper only uses fgetcsv() and fputcsv(). SO a PHP version 5 or higher is required.

Update: Found an alternative for using str_getcsv(), so for PHP versions supporting str_getcsv() this function is still used, for those not supporting str_getcsv() the alternative function is used. So theoretical the plugin can be used with PHP 5 or higher

Note: The alternative function is not tested sufficiently. Use with caution.

Currently the plugin works using fputcsv(), fgetcsv() and str_getcsv(), so a PHP version 5.3.0 or higher is required. I am working on another solution allowing it to use the plugin with PHP 5 or higher.

Supported CMSimple versionsBack to top

InstallationBack to top

Note that in CMSimple 4.7 or later, the CRSF protection needs to be disabled in order change configuration options. This means setting $cf['use']['csrf_protection']="false"; in cmsimple/config.php.

CMSimple XHBack to top

CMSimple 3.3 and CMSimple LEBack to top

The images are taken in CMSimple 3.3, but should help installing the plugin in CMSimple LE, too.

$cf['plugins']['folder'] = "plugins";
CMSimple 3.3 settings. CMSimple plugins_folder configuration.

UpgradingBack to top

1.0.x to 1.1.xBack to top

The data (CSV with videos) should be compatible between this version. Do not overwrite plugins/youtube/list.csv and your videos will be kept available.

1.1.x to 1.2.xBack to top

Between these versions there were made many changes. Instead of using one list of youtube videos 1.2.x supports the creation of different galleries of videos. The format of the CSV files (list.csv for 1.1.x and the gallery CSV files in 1.2.x) is the same, but the gallery CSV files of 1.2.x are store by default in content/plugins/youtube/galleryname.csv. So for updating it should work by copying list.csv into content/plugins/youtube/list.csv (or into the directory specified by the filepath option in the configuration). Another small difference is the internal used and in 1.2.x shown id (not the youtube id), 1.2.x uses a current timestamp, whereas 1.1.x uses an own routine for defining a new id, so after updating to 1.2.x the dates shown in backend of the old videos will not make much sense, but that should not be any problem!

1.2.x to 1.3.xBack to top

The csv scheme changed slightly: The width and height of each video are stored. So make sure you add a width and height to each video. If not the plugin will choose a default width and height which is configurable in the configuration: default_video_width and default_video_height.

ConfigurationBack to top

Configuration can either be done by directly editing config.php or by using the backend.

Configuration optionsBack to top

There is no need to edit csv_filepath, csv_delimiter or csv_enclosure. Important: Do not edit these settings in production environments, all old galleries and videos won't be read correctly.

The configuration fileBack to top

* Filepath storing CSV containing videos.
* @warning NOTE: Without '/' at the end! 
* @var
$plugin_cf['youtube']['csv_filepath'] = "content/plugins/youtube";
* Delimiter for CSV. 
* @var
$plugin_cf['youtube']['csv_delimiter'] = "#";
* Enclosure for CSV.
* @var
$plugin_cf['youtube']['csv_enclosure'] = "\"";
* Date format used in backend.
* @var
$plugin_cf['youtube']['date_format'] = "d.m.Y";
* Default width of a video.
* @var
$plugin_cf['youtube']['video_default_width'] = "420";
* Default height of a video.
* @var
$plugin_cf['youtube']['video_default_height'] = "315";

Backend configurationBack to top

See the help texts of the options to see if your changes are valid.

Backend configuration.

UsageBack to top

Getting StartedCalling the pluginBack to top

For calling the plugin on some of your pages use one of the following scripts:

The function expects one parameter: A string defining the gallery to show. The string must be the same as the gallery name in backend.

BackendBack to top

Select the plugin in your CMSimple backend. You will see some information about the plugin:

Youtube information of installed version.

Click "Manage galleries" in the toolbar.

The first thing to do is to create a gallery.

Create the first gallery.

Managing galleriesBack to top

NOTE: It is recommended to use a name without any whitespace or special (for example non-ascii) characters. The gallery name is used as file name for the CSV file storing the videos, so use only valid names for files.

There are several options managing the galleries:

New galleriesBack to top

For creating a new gallery click the "New gallery" link. The form is the same as for creating the first gallery.

Deleting a galleryBack to top

For deleting a gallery click the "Remove gallery" link when the wished gallery is selected. You will be asked if you are sure you want to delete the gallery. If there are still videos in the gallery they will be deleted, too.

Delete gallery.

Managing videosBack to top

There are several options to manage the videos in a gallery:


How about using special characters and quotiation marks within the fields?

Currently special characters and especially quotation marks can be used for the title, the description and the link title. This is accomplished using a combination of using htmlspecialchars($content, ENT_QUOTES) for saving the data to the CSV file and using html_entity_decode() for displaying the descritpion. So the conclusion: the title can not be filled with HTML code. For the description the use of HTML code is ok.

Note: There can still be combinations of characters this solution does not work for!

Adding a new videoBack to top

For adding a new video click the "Add"-Button (the green plus-symbol). A title and a Youtube ID is required, the description and position of the video is optional, if no position is given the order of the video is dependant on the CSV file the videos are saved in. If no description is given the description-div will not be printed.

Add video.
How to get the Youtube ID?Back to top

Go to Youtube and select a video:

Get Youtube ID.

Successfully added the video:

Successfully saved video.

Editing a videoBack to top

Editing a video is similar to adding a new one. For editing a video click the "Edit"-Button in the row of the video. You will see the form filled with the current data.

Deleting a videoBack to top

For deleting a video click the "Delete"-Button in the row of the video. You will be asked if you are sure you want to delete the video:

Delete video.

After clicking "I'm sure.":

Successfully deleted video.

Custom stylingBack to top

Custom styling can either be done in the templates stylesheet or by modifying the plugin's stylesheet. The plugin's stylesheet is located in plugins/youtube/css. Delete the frontend part in the stylesheet of the plugin if you want to do custom styling in the template's stylesheet.

The frontend part of the stylesheet looks like this:

 * Frontend style.

/* The title div. */
.youtube-title {
	margin: 1em auto;
	border-bottom: 1px solid #777;
	font-size: 18pt;
	font-weight: bold;
	padding: 10px 0;

/* The video div. */
.youtube-video {
	margin: 1em auto;

/* The description div. */
.youtube-description {
	border: 1px solid #777;
	padding: 10px;
	margin: 1em 0;


IconsBack to top

All icons used in the backend of this plugin are part of the spirit20 icons set (licensed under GPL). See here For the complete set. Thanks to Dale Morrell for this great set of icons!

ChangelogBack to top

Version 1.3Back to top

Version 1.3.2

Version 1.3.1

Version 1.3.0

Beta 5.

Up to Beta 4.

Beta 1.

LicenseBack to top

The plugin is published under the GNU Public License Version 3. For more information see: GNU Licenses

The plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.