-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #525 from BitBagCommerce/feature/OP-328
OP-328: Update readme, docs and add UPGRADE-5.0.md
- Loading branch information
Showing
75 changed files
with
608 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# UPGRADE FROM 4.2 TO 5.0 | ||
|
||
This upgrade is a major one, as it introduces a new feature - [Content Elements](doc/content_elements.md) | ||
and removes the old way of creating blocks and pages. | ||
|
||
* A lot of database modifications has been made. Read the below changelog first and then migrate your structure using | ||
`bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate` commands. | ||
* Sections are now Collections, as it was a more suitable name for the feature. | ||
* Pages and Blocks now have `Content elements` segment, where you can add elements to the page or block. | ||
* Removed FAQ, as you can now create a FAQ page with the new content elements. | ||
* Added new `Templates` section where you can create templates for your content elements. Read more about it in [Use case templates](doc/use_case_templates.md) | ||
and [Templates](doc/templates.md) docs. | ||
* Removed CKEditor deprecation modal. | ||
* Reordered forms/elements for functionality consistency. | ||
* Updated import functionality to work with the new structure. | ||
* Updated fixtures to work with the new structure | ||
* Removed `bitbag_cms_render_product_pages` twig extension. | ||
* Removed support for rendering twig functions in WYSIWYG editor. | ||
* Added twig extensions: | ||
* `bitbag_cms_render_collection` | ||
* `bitbag_cms_render_content_elements` | ||
|
||
## Briefly about Content Elements | ||
|
||
Content elements is a new segment in the block/page form where you can add elements that will be rendered on the store's frontend, like: | ||
* Textarea | ||
* Heading | ||
* Images | ||
* Products carousel | ||
* etc. | ||
|
||
> Read more about the content elements in the updated [Content elements](doc/content_elements.md) doc. | ||
## Changes in Collections (old Sections) | ||
|
||
### Added fields: | ||
|
||
* Type | ||
* Pages/Block/Media (depending on the chosen type) | ||
|
||
### Moved fields: | ||
|
||
* Name field has been moved from translations to the main settings tab | ||
|
||
> Read more about the collections in the updated [Use case collections](doc/use_case_collections.md) and [Collections](doc/collections.md) docs. | ||
## Changes in Pages | ||
|
||
### Removed fields: | ||
|
||
* Products | ||
* Breadcrumb | ||
* Name when linked | ||
* Description when linked | ||
* Image | ||
* Content | ||
* Title | ||
|
||
### Added fields | ||
|
||
* Teaser title | ||
* Teaser content | ||
* Teaser image | ||
|
||
### Moved fields | ||
|
||
* Name field has been moved from translations to the main settings tab | ||
|
||
> Read more about the pages in the updated [Use case pages](doc/use_case_pages.md) and [Pages](doc/pages.md) docs. | ||
## Changes in Blocks | ||
|
||
### Removed fields: | ||
|
||
* Products | ||
* Taxons | ||
* Whole translations tab | ||
|
||
### Added fields | ||
|
||
* Name | ||
* Locales | ||
* Display for products | ||
* Display for products in taxons | ||
* Display for taxons | ||
|
||
> Read more about the blocks in the updated [Use case blocks](doc/use_case_blocks.md) and [Blocks](doc/blocks.md) docs. | ||
## Changes in Media | ||
|
||
### Removed fields: | ||
|
||
* Products | ||
|
||
### Added fields | ||
|
||
* Media preview with path | ||
|
||
### Moved fields | ||
|
||
* Name field has been moved from translations to the main settings tab | ||
|
||
### Renamed fields | ||
|
||
* Content -> Link content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Collections | ||
|
||
Collections are a way to group multiple pages, blocks or media together. | ||
They are useful for organizing things in a way that makes sense to you. \ | ||
For example, you might want to group all of your blog posts together in a collection called `Blog`. | ||
Or you might want to group all of your specific blocks together in a collection called `Homepage blocks`. | ||
|
||
## General usage | ||
|
||
### Rendering the collection | ||
|
||
In the admin panel, you can create collection resources. | ||
It could be rendered in your twig templates using `bitbag_cms_render_collection([collection_code])` helper extension. | ||
|
||
`{{ bitbag_cms_render_collection([collection_code]) }}` function can also take two additional parameters: `countToRender` and `template`. | ||
|
||
`countToRender` allows you to render a specific number of items from the collection. For instance: | ||
|
||
```twig | ||
{{ bitbag_cms_render_collection('homepage_blocks', 3) }} | ||
``` | ||
|
||
`template` allows you to render a collection with a custom template. For instance: | ||
|
||
```twig | ||
{{ bitbag_cms_render_collection('homepage_blocks', null, '@App/Some/Template/_path.html.twig') }} | ||
``` | ||
|
||
By default, collection items are sorted by object ID parameter. If you want to change it, you can use decorator strategy. | ||
You can read more about it [here](https://symfony.com/doc/current/service_container/service_decoration.html). | ||
|
||
## Customization | ||
|
||
### Override collection template | ||
|
||
If you don't know how to override templates yet, read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). | ||
|
||
Even if you can pass template argument to render collection resource, you can change the global templates under `app/templates/bundles/BitBagSyliusCmsPlugin/Shop/Collection` location. | ||
Available templates you can override can be found under [this location](../src/Resources/views/Shop/Collection). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Content elements | ||
|
||
Content elements are used to create a page or block content that will be displayed on the store's frontend. | ||
|
||
## General usage | ||
|
||
Currently, there are 11 predefined content elements available: | ||
- **[Textarea](content_elements/textarea.md)** - a simple textarea with WYSIWYG editor | ||
- **[Single media](content_elements/single_media.md)** - a single media from the media library | ||
- **[Multiple media](content_elements/multiple_media.md)** - multiple media from the media library | ||
- **[Heading](content_elements/heading.md)** - a simple heading from h1 to h6 | ||
- **[Products carousel](content_elements/products_carousel.md)** - a carousel with products | ||
- **[Products carousel by Taxon](content_elements/products_carousel_by_taxon.md)** - a carousel with products from a specific taxon | ||
- **[Products grid](content_elements/products_grid.md)** - a grid with products | ||
- **[Products grid by Taxon](content_elements/products_grid_by_taxon.md)** - a grid with products from a specific taxon | ||
- **[Taxons list](content_elements/taxons_list.md)** - a list of taxons | ||
- **[Pages collection](content_elements/pages_collection.md)** - a collection of pages | ||
- **[Spacer](content_elements/spacer.md)** - a simple spacer with a defined height in pixels | ||
|
||
Instead of rendering block or page, you can render just content elements in your twig templates using `bitbag_cms_render_content_elements([page|block])` helper extension, | ||
where `page` or `block` is an instance of `BitBag\SyliusCmsPlugin\Entity\PageInterface` or `BitBag\SyliusCmsPlugin\Entity\BlockInterface`. | ||
|
||
## Customization | ||
|
||
### Templates | ||
|
||
Each of the content elements has its own template that you can override. | ||
|
||
If you don't know how to override templates yet, | ||
read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). | ||
|
||
You can create a template under `app/templates/bundles/BitBagSyliusCmsPlugin/Shop/ContentElement` location. | ||
Available templates you can override can be found under [this location](../src/Resources/views/Shop/ContentElement). | ||
|
||
### Creating a new content element | ||
|
||
If you want to create a new content element, you need to follow these steps: | ||
|
||
1. Create a new form type under `src/Form/Type/ContentElements` location. Define your fields and remember to define public const `TYPE` with a unique name. | ||
For example, you can create a new form type called `Text`: | ||
|
||
```php | ||
final class TextContentElementType extends AbstractType | ||
{ | ||
public const TYPE = 'text'; | ||
|
||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add(self::TYPE, TextType::class, [ | ||
'label' => 'bitbag_sylius_cms_plugin.ui.content_elements.type.' . self::TYPE, | ||
]) | ||
; | ||
} | ||
} | ||
``` | ||
|
||
2. Define constant parameter in `config/parameters.yaml` or yours any other `yaml` file: | ||
|
||
```yaml | ||
parameters: | ||
bitbag_sylius_cms_plugin.content_elements.type.text: !php/const 'YourNamespace\Form\Type\ContentElements\TextContentElementType::TYPE' | ||
``` | ||
3. Define form type in service container under `config/services.yml` with correct tags: | ||
|
||
```yaml | ||
services: | ||
bitbag_sylius_cms_plugin.form.type.content_element.text: | ||
class: YourNamespace\Form\Type\ContentElements\TextContentElementType | ||
tags: | ||
- { name: 'bitbag_sylius_cms_plugin.content_elements.type', key: '%bitbag_sylius_cms_plugin.content_elements.type.text%' } | ||
- { name: 'form.type' } | ||
``` | ||
|
||
4. Create a new renderer class under `src/Renderer/ContentElement` location. Implement `BitBag\SyliusCmsPlugin\Renderer\ContentElement\ContentElementRendererInterface` interface. | ||
For example, you can create a new renderer called `TextContentElementRenderer`: | ||
|
||
```php | ||
final class TextContentElementRenderer implements ContentElementRendererInterface | ||
{ | ||
public function __construct(private Environment $twig) | ||
{ | ||
} | ||
public function supports(ContentConfigurationInterface $contentConfiguration): bool | ||
{ | ||
return TextContentElementType::TYPE === $contentConfiguration->getType(); | ||
} | ||
public function render(ContentConfigurationInterface $contentConfiguration): string | ||
{ | ||
$text = $contentConfiguration->getConfiguration()['text']; | ||
return $this->twig->render('@BitBagSyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ | ||
'content_element' => '@YourNamespace/Shop/ContentElement/_text.html.twig', | ||
'text' => $text, | ||
]); | ||
} | ||
} | ||
``` | ||
|
||
5. Register your renderer with tag in service container under `config/services.yml`: | ||
|
||
```yaml | ||
services: | ||
bitbag_sylius_cms_plugin.renderer.content_element.text: | ||
class: YourNamespace\Renderer\ContentElement\TextContentElementRenderer | ||
arguments: | ||
- '@twig' | ||
tags: | ||
- { name: 'bitbag_sylius_cms_plugin.renderer.content_element' } | ||
``` | ||
|
||
6. Finally, create a new template under `templates/bundles/BitBagSyliusCmsPlugin/Shop/ContentElement` location. | ||
For example, you can create a new template called `_text.html.twig`: | ||
|
||
```twig | ||
<p>{{ text }}</p> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Heading content element | ||
|
||
Heading content element allows you to add a heading (from H1 to H6) to your block or page. | ||
|
||
## View in admin panel | ||
|
||
![Heading in admin panel](heading1.png) | ||
|
||
## View in front page | ||
|
||
![Heading in front page](heading2.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Multiple media content element | ||
|
||
Multiple media content element allows you to add multiple media (images, videos, or files) | ||
from the media library to your block or page. | ||
|
||
## View in admin panel | ||
|
||
![Multiple media in admin panel](multiple_media1.png) | ||
|
||
## View in front page | ||
|
||
![Multiple media in front page](multiple_media2.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.