There I will show my evryday working with Libra CMS.
I have globaly installed composer.phar and aliased to just composer.
I start with
git clone https://github.com/libracms/libra-cms.git new-project
cd new-project
composer update
This will Install libra cms (Of course you should set up DB access import sql).
After I add it to my repository by
git remote rename origin upstream
git remote add origin https://bitbucket.org/username/my-project.git
Now I can freely pull new changes from upstream and merge them with master.
Next step
Now I will prefer work in module Application or create some new module. For novice I recommend to use the Application module for advanced user to create a new module.
I'm going to module/Application/view/layout/default and create my new website template. I copy assets into Application/public folder. Then they will be accessible by url /basename/module/application/css/screen.css
'default' - is the name of you default template. You can have several template and switch between them by 'layoutName' parameter in config/autoload/libra-app.global.php file.
Advanced changing of libra-artilce module
Some time you feel lack of fields in article form. You can add some new fields by attaching events to LibraArticle\Controller\ArticleController.
Module awares of events as: form.init, get, save.pre, create.post, update.post, save.post; view.
As example we will add field 'heading2'. For this you should attach events:
public function onBootstrap(MvcEvent $e) { $sharedManager = $e->getApplication()->getEventManager()->getSharedManager(); $sharedManager->attach('LibraArticle\Controller\ArticleController', 'dispatch', function($e) { // Add current article to layout $controller = $e->getTarget(); $controller->getEventManager()->attach('view', function($e) { $article = $e->getParam('article'); $controller = $e->getTarget(); $controller->layout()->setVariable('article', $article); }); }, 100); $sharedManager->attach('LibraArticle\Controller\AdminArticleController', 'dispatch', function($e) { $controller = $e->getTarget(); $controller->getEventManager()->attach('save.post', function($e) { $article = $e->getParam('article'); $data = $e->getParam('data'); $article->setParam('heading2', $data['heading2']); // Return true to save changes to DB return true; }); $controller->getEventManager()->attach('get', function($e) { $article = $e->getParam('article'); $data = $e->getParam('data'); $data['heading2'] = $article->getParam('heading2'); }); $controller->getEventManager()->attach('form.init', function($e) { $form = $e->getParam('form'); // Add specefic inputs $form->getInputFilter()->add(array( 'name' => 'heading2', 'required' => false, )); $form->add(array( 'type' => 'Text', 'name' => 'heading2', 'options' => array( 'label' => 'Heading 2', ), )); return null; }); }, 100); }
Then add this field to copy of edit.phtml to your Application/view/libra-article/admin-article folder (copy it from vendor view).
Highlighted code can be finded on gits.
Using auto resizing of images
Nex I describe how use libra-article-zooming module to get zoomed images into article.
For this add zoom class to your image and set it sizes lesser than original.