@@ -5,12 +5,12 @@ Building blocks
5
5
Building blocks, also known as snippets, are how users design and layout pages. They are important
6
6
XML elements of your design.
7
7
8
- The building blocks are classified into four categories :
8
+ The building blocks are classified into two types :
9
9
10
- #. **Structure blocks **: to give a basic structure to the website
11
- #. ** Feature blocks **: to describe the features of a product or service
12
- #. ** Dynamic Content blocks **: blocks that are animated or interact with the backend
13
- #. **Inner Content blocks **: blocks used inside other building blocks
10
+ #. **Structure blocks **: visually used as "whole rows" and distributed into multiples categories
11
+ ( :guilabel: ` Intro `, :guilabel: ` Columns `, :guilabel: ` Content `, :guilabel: ` Images `,
12
+ :guilabel: ` People `, etc)
13
+ #. **Inner Content blocks **: used inside other building blocks
14
14
15
15
At the end of this chapter, you will be able to :ref: `create custom snippets
16
16
<website_themes/building_blocks/custom>` and to add them into a dedicated category.
@@ -427,15 +427,21 @@ snippet (e.g., :file:`001.js`, :file:`002.scss`).
427
427
Custom snippet
428
428
==============
429
429
430
- To create a custom snippet, create first the snippet template. Then, add it to the list and make it
431
- available via the Website Builder.
430
+ Some more specific needs will require the creation of custom snippets. Here is how to create a
431
+ custom snippet/
432
432
433
433
.. _website_themes/building_blocks/custom/template :
434
434
435
435
Template
436
436
--------
437
437
438
- **Declaration **
438
+ Create first the snippet template. Then, add it to the list and make it available via the Website
439
+ Builder.
440
+
441
+ 1. Declaration
442
+ ~~~~~~~~~~~~~~
443
+
444
+ First, create the template of the custom snippet:
439
445
440
446
.. code-block :: xml
441
447
:caption: ``/website_airproof/views/snippets/s_airproof_snippet.xml``
@@ -464,25 +470,22 @@ Template
464
470
- Avoid using ID attribute within your `section ` as several instances of a snippet may appear
465
471
throughout the page (An ID attribute has to be unique on a page).
466
472
467
- Add your custom snippet to the list of standard snippets, so the user can drag and drop it on the
473
+ Add the custom snippet to the list of standard snippets, so the user can drag and drop it on the
468
474
page, directly from the edit panel.
469
475
476
+ 2. Group creation
477
+ ~~~~~~~~~~~~~~~~~
478
+
479
+ Add a group at the top of the list (feel free to the put it where needed in this list).
480
+
470
481
.. code-block :: xml
471
482
:caption: ``/website_airproof/views/snippets/options.xml``
472
483
473
- <template id =" snippets" inherit_id =" website.snippets" name =" Airproof - Custom Snippets" >
474
- <xpath expr =" //*[@id='default_snippets']" position =" before" >
475
- <t id =" x_theme_snippets" >
476
- <div id =" x_theme_snippets_category" class =" o_panel" >
477
- <div class =" o_panel_header" >Theme</div >
478
- <div class =" o_panel_body" >
479
- <t t-snippet =" website_airproof.s_airproof_snippet" t-thumbnail =" /website_airproof/static/src/img/wbuilder/s_airproof_snippet.svg" >
480
- <keywords >Snippet</keywords >
481
- </t >
482
- </div >
483
- </div >
484
- </t >
485
- </xpath >
484
+ <template id =" snippets" inherit_id =" website.snippets" name =" Airproof - Snippets" >
485
+ <!-- Create the group -->
486
+ <xpath expr =" //snippets[@id='snippet_groups']/*[1]" position =" before" >
487
+ <t snippet-group =" airproof" t-snippet =" website.s_snippet_group" string =" Airproof" t-thumbnail =" /website_airproof/static/src/img/wbuilder/s_airproof_group_thumbnail.svg" />
488
+ </xpath >
486
489
</template >
487
490
488
491
.. list-table ::
@@ -492,13 +495,76 @@ page, directly from the edit panel.
492
495
493
496
* - Attribute
494
497
- Description
498
+ * - snippet-group
499
+ - ID of the group
495
500
* - t-snippet
496
- - The template to use
501
+ - Inherited template ID
502
+ * - string
503
+ - Group name displayed to the users
497
504
* - t-thumbnail
498
- - The path to the snippet thumbnail
505
+ - The path to the thumbnail of the group
506
+
507
+ 3. Snippet addition
508
+ ~~~~~~~~~~~~~~~~~~~
509
+
510
+ Then add the custom snippet into the `<snippets id="snippet_structure"> ` which contains
511
+ all existing ones on the same level. The Website Builder will split them automatically into
512
+ categories by reading the `group ` attribute on the `<t t-snippet=""> `
513
+
514
+ .. code-block :: xml
515
+ :caption: ``/website_airproof/views/snippets/options.xml``
516
+ :emphasize-lines: 7-12
517
+
518
+ <template id =" snippets" inherit_id =" website.snippets" name =" Airproof - Snippets" >
519
+ <!-- Create the group -->
520
+ <xpath expr =" //snippets[@id='snippet_groups']/*[1]" position =" before" >
521
+ <t snippet-group =" airproof" t-snippet =" website.s_snippet_group" string =" Airproof" t-thumbnail =" /website_airproof/static/src/img/wbuilder/s_airproof_group_thumbnail.svg" />
522
+ </xpath >
523
+
524
+ <!-- Add the custom snippet to the group -->
525
+ <xpath expr =" //snippets[@id='snippet_structure']/*[1]" position =" before" >
526
+ <t t-snippet =" website_airproof.s_airproof_snippet" string =" Custom snippet" group =" airproof" >
527
+ <keywords >Snippet</keywords >
528
+ </t >
529
+ </xpath >
530
+ </template >
531
+
532
+ .. list-table ::
533
+ :header-rows: 1
534
+ :stub-columns: 1
535
+ :widths: 20 80
536
+
537
+ * - Attribute
538
+ - Description
539
+ * - t-snippet
540
+ - The snippet template to use
541
+ * - group
542
+ - The group in which the snippet is added.
499
543
* - <keywords>
500
544
- Keywords entered by the user in the search field in the Snippets panel
501
545
546
+ Inner content snippet
547
+ ~~~~~~~~~~~~~~~~~~~~~
548
+
549
+ To make a custom snippet appearing in the :guilabel: `Inner content ` list, add it to the `snippet_content `
550
+ instead:
551
+
552
+ .. code-block :: xml
553
+ :caption: ``/website_airproof/views/snippets/options.xml``
554
+
555
+ <template id =" snippets" inherit_id =" website.snippets" name =" Airproof - Snippets" >
556
+ <!-- Add the custom snippet to the group -->
557
+ <xpath expr =" //snippets[@id='snippet_content']/*[1]" position =" before" >
558
+ <t t-snippet =" website_airproof.s_airproof_snippet" string =" Custom snippet" t-thumbnail =" /website_airproof/static/src/img/wbuilder/s_airproof_snippet.svg" />
559
+ </xpath >
560
+ </template >
561
+
562
+ .. important ::
563
+ - Don't forget to add a `t-thumbnail ` and remove the `group ` attribute as this kind of building
564
+ blocks is directly available in the right options panel of the Website Builder.
565
+ - Don't forget to :ref: `add the snippet to the list of all available "Inner content" snippets
566
+ <website_themes/building_blocks/custom/options/inner_content>`.
567
+
502
568
.. _website_themes/building_blocks/custom/options :
503
569
504
570
Options
@@ -508,7 +574,7 @@ Options allow users to edit a snippet's appearance/behavior using the Website Bu
508
574
snippet options easily and automatically add them to the Website Builder.
509
575
510
576
.. seealso ::
511
- `Standard snippet options <https://github.com/odoo/odoo/blob/ccb78f7af2a4413836a969ff8009dc3df6c2df33 /addons/website/views/snippets/snippets.xml >`_
577
+ `Standard snippet options <https://github.com/odoo/odoo/blob/247f28fdec788c7eb7c4288db29b931c73a23757 /addons/website/views/snippets/snippets.xml >`_
512
578
513
579
.. _website_themes/building_blocks/custom/options/template :
514
580
@@ -552,6 +618,8 @@ Then insert the different available options:
552
618
</xpath >
553
619
</template >
554
620
621
+ .. _website_themes/building_blocks/custom/options/inner_content :
622
+
555
623
**Inner content **
556
624
557
625
Make a custom snippet "inner content" (droppable in an other building block) by extending the
@@ -570,7 +638,7 @@ inner content building blocks:
570
638
571
639
.. seealso ::
572
640
573
- `Standard "inner content" snippets declaration on Odoo's GitHub repository <https://github.com/odoo/odoo/blob/f922f09b83c68dff36c064d20709a6e6ba4541dc /addons/website/views/snippets/snippets.xml#L720 >`_
641
+ `Standard "inner content" snippets declaration on Odoo's GitHub repository <https://github.com/odoo/odoo/blob/cc05d9d50ac668eaa26363e1127f914897a4b125 /addons/website/views/snippets/snippets.xml#L988 >`_
574
642
575
643
.. _website_themes/building_blocks/custom/options/binding :
576
644
@@ -949,9 +1017,9 @@ There are also built-in methods directly linked to events the Website Builder li
949
1017
950
1018
.. seealso ::
951
1019
- `Web Editor - JavaScript methods related to snippet options on GitHub
952
- <https://github.com/odoo/odoo/blob/380c9153b5fa9a0ea6d7ae485ef52a16ae999eda /addons/web_editor/static/src/js/editor/snippets.options.js#L3247 > `_
953
- - `XML templates of the different snippets
954
- <https://github.com/odoo/odoo/blob/ccb78f7af2a4413836a969ff8009dc3df6c2df33 /addons/website/views/snippets/snippets.xml> `_
1020
+ <https://github.com/odoo/odoo/blob/cc05d9d50ac668eaa26363e1127f914897a4b125 /addons/web_editor/static/src/js/editor/snippets.options.js#L3512 > `_
1021
+ - `XML templates of the different standard snippets
1022
+ <https://github.com/odoo/odoo/blob/cc05d9d50ac668eaa26363e1127f914897a4b125 /addons/website/views/snippets/snippets.xml> `_
955
1023
956
1024
.. _website_themes/building_blocks/custom/options/methods/custom :
957
1025
0 commit comments