Automatically create a file set?
Permalink
Hi,
I'm developing a new theme, is there a way I can make the theme automatically create a file set with the name 'Background Image' when it is installed?
Obviously it should check if that set exists first then create it if necessary.
Thanks in advance :)
Dave
I'm developing a new theme, is there a way I can make the theme automatically create a file set with the name 'Background Image' when it is installed?
Obviously it should check if that set exists first then create it if necessary.
Thanks in advance :)
Dave
According to
http://www.concrete5.org/documentation/developers/files/grouping-fi...
you can create a fileset with :
You can by example use this in your install() function of your controller.php package.
http://www.concrete5.org/documentation/developers/files/grouping-fi...
you can create a fileset with :
$fs = FileSet::createAndGetSet($name, $type, $uID = false) Creates a new file set if set doesn't exist. Type may be one of the following FileSet::TYPE_PRIVATE FileSet::TYPE_PUBLIC FileSet::TYPE_STARRED
You can by example use this in your install() function of your controller.php package.
That's the page I was looking for!
Thanks guys, much appreciated! :)
Thanks guys, much appreciated! :)
Is it sufficient to add it in the controllers install function like this:
public function install() {
$pkg = parent::install();
$fs = FileSet::createAndGetSet('Background Image', FileSet::TYPE_PUBLIC, $uID = false);
PageTheme::add('street', $pkg);
}
public function install() {
$pkg = parent::install();
$fs = FileSet::createAndGetSet('Background Image', FileSet::TYPE_PUBLIC, $uID = false);
PageTheme::add('street', $pkg);
}
Yes, should be ok from a package controller as you have described.
As always, best to test it to make sure.
As always, best to test it to make sure.
Cool I'll test it later, thanks John!
Tried to install it on a test site in WAMP and got this error:
( ! ) Fatal error: Class 'FileSet' not found in C:\wamp\www\street_theme\packages\street\controller.php on line 21
Here's my controller.php:
( ! ) Fatal error: Class 'FileSet' not found in C:\wamp\www\street_theme\packages\street\controller.php on line 21
Here's my controller.php:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); class StreetPackage extends Package { protected $pkgHandle = 'street'; protected $appVersionRequired = '5.5.2'; protected $pkgVersion = '0.93'; public function getPackageDescription() { return t("Installs Street theme."); } public function getPackageName() { return t("Street Theme"); } public function install() { $pkg = parent::install(); $fs = FileSet::createAndGetSet('Background Image', FileSet::TYPE_PUBLIC, $uID = false);
Viewing 15 lines of 18 lines. View entire code block.
It may be that the model is not loaded automatically at this stage.
Try
Try
Loader::model('file_set');
That was it, thanks John! :)
as per
http://www.concrete5.org/documentation/developers/files/grouping-fi...