Content Sections

Content sections are the default section types. The types you create by clicking or dragging the “Add new Section” button in the WordPress Admin. Usually when we’re talking about sections we’ll be mentioning the default content sections.


Classes

There are some classes associated with default content sections which are:

Base class: \CuisineSections\SectionTypes\ContentSections
Template class: \CuisineSections\Templates\ContentSectionTemplate
Collection class: \CuisineSections\Collections\SectionCollection

Admin logic: \CuisineSections\Admin\Handlers\SectionHandler
Admin ui: \CuisineSections\Admin\Ui\Sections\BaseSectionUI


Base Class:

Deals with all the properties of a default section. Among these properties you’ll find stuff like the chosen view, the position on the page and the associated columns. The ContentSection class extends the BaseSection class.


Template Class:

The template class makes sure the right template files get loaded in the front-end for this section. You can find more information about template classes for sections here


Collection class:

This is the collection of sections for a regular page or other post-type. The base class is a single item in the collection class. The SectionCollection simply contains all sections tied to a specific post-type.


Admin logic:

Saving, editting and sorting the sections on a specific page all happen in the SectionHandler.


Admin UI

The basic UI of a content section.


The attributes API.

A section has, like we’ve discussed above, different attributes like the ID, template name or columns. Each section type has different attributes. Which is why you can overrule them if you’re ever extending the class by using the following code:

/**
 * Returns all public attributes
 * 
 * @return array
    */
public function getAttributes()
{
    $attributes = parent::getAttributes();
    $containerAttributes = [
        'sections',
        'container-type'
    ];

    return array_merge( $attributes, $containerAttributes );
}

This function adds two new attributes to the container section-type; sections and the container-type. From now on these values will be available in the section template and other places.