We created a demo app with some useful use-cases of the plugin! Visit cms.bitbag.shop to take a look at it. The admin as always can be accessed under cms.bitbag.shop/admin link and sylius: sylius
credentials.
Almost each eCommerce app has to present some content. Managing it is often done via third-party libraries like Wordpress, eZ Platform or a built-in content management system. As Sylius does not have a CMS in the standard platform, we decided to develop our own which will be as flexible as Sylius. This plugin allows you to add dynamic blocks with images, text or HTML to your storefront as well as pages and FAQs section.
$ composer require bitbag/cms-plugin
$ bin/console doctrine:schema:update --force
$ bin/console assets:install
Add plugin dependencies to your AppKernel.php file:
public function registerBundles()
{
return array_merge(parent::registerBundles(), [
...
new BitBag\CmsPlugin\BitBagCmsPlugin(),
]);
}
Import required config in your app/config/config.yml
file:
# app/config/config.yml
imports:
...
- { resource: '@BitBagCmsPlugin/Resources/config/config.yml' }
Import routing in your app/config/routing.yml
file:
# app/config/routing.yml
...
bitbag_cms_plugin:
resource: '@BitBagCmsPlugin/Resources/config/routing.yml'
If you don't know how to override templates yet, read Sylius template customization guide.
In the admin panel, you can now create image and text blocks. Both can be rendered in your twig templates using bitbag_render_block([block_code])
helper extension.
For instance, let's assume you have created a block with homepage_text_block
code and want to render it on store homepage.
In your app/Resources/views/SyliusShopBundle/Homepage/index.html.twig
file add the twig filter like this:
{% extends '@SyliusShop/layout.html.twig' %}
{% block content %}
{{ render(path('bitbag_shop_block_render', {'code' : 'homepage_header_image', 'template' : '@App/Some/Template/_path.html.twig'})) }}
{{ bitbag_render_block('homepage_text_block') }}
{% endblock %}
To render a block by the product code, you can use route
.
{{ render(path('bitbag_shop_block_index_by_product_code', {'productCode' : product.code, 'template' : '@BitBagCmsPlugin/Shop/Block/index.html.twig'})) }}
You can render page in two ways:
By rendering a page link template:
{{ render(path('bitbag_shop_page_show_link_by_code', {'code' : 'about', 'template' : '@BitBagCmsPlugin/Shop/Page/Show/_link.html.twig'})) }}
Or rendering a page link directly:
{{ render(path('bitbag_shop_page_show', {'slug' : 'about'})) }}
With sections, you can organize your blocks and pages under some specific categories. For instance, you can create a Blog section and display pages and blocks under it. You also have a set of routes to do it:
<a href="{{ path('bitbag_shop_page_index_by_section_code', {'sectionCode' : 'blog'}) }}">
{{ 'app.ui.blog'|trans }}
</a>
{{ render(path('bitbag_shop_block_index_by_section_code', {'sectionCode' : 'blog', 'template' : '@BitBagCmsPlugin/Shop/Block/index.html.twig'})) }}
To render FAQs list, use the bitbag_shop_frequently_asked_question_index
route.
<a href="{{ path('bitbag_shop_frequently_asked_question_index') }}">{{ 'app.ui.faqs'|trans }}</a>
Sometimes you'll need to set up your environment quickly or even load some primary CMS data on your server. You can take a look at tests/Application/app/config/fixtures.yml
file to see how you can configure fixtures.
For now you can install CKEditor, create proper form extension and replace Textarea[Text]Type::class
with CKEditorType::class
.
For more - take a look at FriendsOfSylius WYSIWYG step by step guide.
To see which forms you may want to extend, run $ bin/console debug:container | grep bitbag.cms_plugin.form
command.
Go to the tests/Application/app/Resources
or visit cms.bitbag.shop demo page.
$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console assets:install web -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d web -e test
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run
Learn more about our contribution workflow on http://docs.sylius.org/en/latest/contributing/.
Want us to help you with this plugin? Write us an email on mikolaj.krol@bitbag.pl 💻