Strange code
Permalink
I found this code but I can't understand what it is for
I found this code in this pagehttp://www.concrete5.org/documentation/developers/system/submit-the...
Where I should put this code and for what reason should I do?
Thank you
Loader::model('collection_types'); if(!is_object(CollectionType::getByHandle('home')) { $data['ctHandle'] = 'home'; $data['ctName'] = t('Home'); $hpt = CollectionType::add($data, $pkg); }
I found this code in this pagehttp://www.concrete5.org/documentation/developers/system/submit-the...
Where I should put this code and for what reason should I do?
Thank you
This code is to check that the page type you are adding(if you are going to add a page type) does not already exist. Maybe with these handles and names it makes more sense.
This is only if you create a new page type.
Example, all your 'home' would be the page type. This would check the if there is another collectiontype named home. If home is not found then it will add it as a new collectiontype. This is to prevent overriding or collectiontype being used by two different types.
Example, all your 'home' would be the page type. This would check the if there is another collectiontype named home. If home is not found then it will add it as a new collectiontype. This is to prevent overriding or collectiontype being used by two different types.
OK but where i should put this code to create automatically a page type?
I have create a theme with about 15 page type but when I want to try the theme in my concrete5 site I have to add manually page types... Can it be automatically with that code?!?!?!
Can you help me?
Thank you
I have create a theme with about 15 page type but when I want to try the theme in my concrete5 site I have to add manually page types... Can it be automatically with that code?!?!?!
Can you help me?
Thank you
You would put that in the install() method of your Package Controller.
Details about halfway down on this page
http://www.concrete5.org/documentation/developers/system/packages/...
Details about halfway down on this page
http://www.concrete5.org/documentation/developers/system/packages/...
I need some help!
If I want to create a theme I have to create a Controller.php file ?
In this file I have to put some code that install the page type o Blocks that i want?
If I want to create a theme I have to create a Controller.php file ?
In this file I have to put some code that install the page type o Blocks that i want?
If you want to "Package" a theme you need to create a controller.php file. This will also be used to install any blocks or page types or anything else you want to add with your theme "package".
OK
Can you write the code to install a theme with a page type?
Thank you
Can you write the code to install a theme with a page type?
Thank you
Don't thank me, thank @j12345 as he's already written it all down for you in this howto.
http://www.concrete5.org/documentation/how-tos/designers/packaging-...
http://www.concrete5.org/documentation/how-tos/designers/packaging-...
But with this code controller.php file will install all page type?
Shouldn't change some code?
Shouldn't change some code?