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 ?
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.