Reputation: 171
While creating page in hybris we create PageTemplate , then content slots. Each content slots has components associated with it. Content Slot is mapped to PageTemplate. finally we map PageTemplate to ContentPage. Thats how Page is created in hybris.
As we already have content slots for page templates which does the work then why do we have ContentSlotName and why should we use it?
Can we avoid it which creating normal content pages and email pages ?
Upvotes: 3
Views: 4905
Reputation: 1593
ContentSlotName is used to indicate cmscockpit/smartedit what type of components can be added in a particular section of the page. For example:
INSERT_UPDATE ContentSlotName; name[unique = true]; template(uid, $contentCV)[unique = true][default = 'loginPageTemplate']; validComponentTypes(code)
; Login-LeftSection ; ; CMSImageComponent
The "Login-LeftSection" is defined in the structure_loginPageTemplate.vm :
td colspan="6" class="structureViewSection">
<cockpit code="Login-LeftSection"/>
</td>
This section was linked with a ContentSlot(i.e LoginLeftContentSlot) when the associated ContentSlotForTemplate was created via the position attribbute:
INSERT_UPDATE ContentSlotForTemplate; $contentCV[unique = true]; uid[unique = true]; position[unique = true]; pageTemplate(uid, $contentCV)[unique = true][default = 'loginPageTemplate']; contentSlot(uid, $contentCV)[unique = true]; allowOverwrite
; ; LoginLeftContent-loginPageTemplate ; Login-LeftSection ; ; LoginLeftContentSlot ; true
As a result the "Login-LeftSection" can be visible in cmscockpit for the login page, and if you try to add a component in the slot associated with that section, only components of CMSImageComponent type will be available for adding (because of the ContentSlotName instance defined above):
So the purpose of the ContentSlotName is to restrict the types of components which can be added for a particular content slot.
The answer to your second question is yes, we can avoid it, but that would mean that any type of components will be available to add in the given content slot.
Update:
The above explanation is valid for newer versions of Hybris where cmscockpit is deprecated and where smartedit is used. Even though smartedit has a different look and feel when it does not allow a component to be added to a certain slot, the the purpose of the ContentSlotName remains the same.
Upvotes: 8
Reputation: 1822
Actually, a ContentSlotName is just a section in your PageTemplate which can be filled with CmsComponents. It can be filled for a PageTemplate (in case you don't want to fill it again and again for each Page using this PageTemplate) or for a Page (in case you want to change the content for every Page).
For example:
It's common practice to reuse ContentSlot like Header and Footer for more PageTemplates (e.g. there is only one ContentSlot "HeaderContent" which is used for all PageTemplates). So if the content of these Slots change, they change for all PageTemplates and all Pages. You have to change them only once for all pages.
In the CMSCockpit, a ContentSlotForTemplate is displayed in red, so you are aware, that you change the PageTemplate and for that reason possibly more than just the Page you are viewing.
Upvotes: 2