KriesiMedia / Enfold-and-WPML

0 stars 0 forks source link

Documentation: Using Custom Elements #4

Open InoPlugs opened 3 years ago

InoPlugs commented 3 years ago

Basics

Using and working with a CET is similar to working with a normal ALB element, but there are a few things you need to know to understand the difference and can take more advantage of this powerfull feature.

To follow this tutorial please use the following settings on WP Dashboard -> Theme Ext4ensions -> Custom Elements:

Custom Elements Management: Editors and Admins Custom Elements Locked Options: Show locked options to all users Checkbox To Show Locked Options: Checked for all users Checkbox Show advanced options: Check

Let us start to explain with a simple ALB button element .

Normal workflow would be:

You might face the following problems if you need more buttons:

At this point a CET can bring you a great help.

The standard ALB button has default settings that are predefined and preselected (we focus only to a few to make it easier to follow):

Let's say, you need a special designed button several times in your site it would help to have your settings already predefined. This is the first use of a CET:

Important: A CET behaves like a normal ALB element but YOUR settings are predefined. For advanced users: the underlying shortcode attributes are modified.

If you later want to change any of these settings:

When you now drag the CET on a page you have the new settings.

Important: All other already existing buttons on your page(s) remain unchanged !!! Only new added buttons have the new settings.

In real world you would like to maintain a consistent layout for your button across your site without the need to edit each button seperatly.

Lets say you must change the color for all your "Contact Me Button" to red:

If you now reload the pages containing this element you will see that all the buttons have turned red (clear server cache if using a cache plugin and browser cache).

Important:

  • Locked values in a CET override any previous value of already existing elements on pages
  • Non locked values in a CET DO NOT change any previous value of already existing elements on pages
  • Locking/Unlocking a value in a CET DOES NOT make any changes to already existing elements on a page, the locked value replaces the original value on the fly on page load. For advanced users: the underlying shortcode attributes on pages are not modified, when executing the shortcode handler a check for locked values returns and replaces the attribute values from the page shortcode.

Locking depending settings:

Have a look at the button setting Button Colors Selection.

Depending on the selection the option Button Color is visible or not. If you want to make sure that the button color Red is used and cannot be changed you also must lock Button Colors Selection. Keep this in mind and be careful, as you cannot be sure what settings are set in the elements on the pages.

The Customize Tab

This tab in a modal popup contains the option "Select a Custom Element to lock values". In our case open the modal popup of a button and you find in the dropdown:

On a page open the modal from:

It is possible to change the underlying Custom Element or back to No Custom Element used - the modal popup is reloaded to reflect the new situation for locked/unlocked values.

This means, if you have an existing page with an ALB button and want this button to have the locked values of a custom element you only need to select this custom element in the list. The other way you can also select another custom element as base for a page element that was originally a CET.

Important: changing the underlying template DOES NOT make any changes to the existing settings of the element on a page. This allows to change and check the styling of an element without loosing your previously made settings when switching around. For advanced users: the underlying shortcode attributes are not changed.

Advanced Option: Hierarchical Custom Elements

This means, that a CET is based on another CET. If the option is set to "Allow use of hierarchical custom elements" then you also have the "Customize Tab" when editing a CET.

This allows to group settings and narrow down the options that can be changed.

Basically the same behaviour as described above, only one big difference:

Important - this behavior is different to the one when used on a page:

When changing to another CET as base the settings of this underlying CET are set as new defaults in this CET - but are not copied when the underlying settings are changed later. When switching back to "No Custom Element used" the existing settings are NOT changed.

Lets have a look at an example, our button element:

Lets say you need a fixed color for all buttons:

Create a CET button "Fixed Color" with color: Red. and lock

Create another CET button "Small":

When using the CET button "Small" on a page you find both color and size locked.

If you change the color to "Blue" in CET button "Fixed Color", the CET button "Small" on the page changes to blue in frontend. The CET button "Small" did not change the color setting RED.

Important: In case you change the hierarchie of CET: Locked values are checked from first parent up ( "Fixed Color" -> "Small" -> .... )

Advanced Option: Custom Elements For Subitems

It is also possible to use CET for elements which open another modal for subiltems like Button Row which has buttons (as Button Row Items).

By default: 'All subitems use the same custom element template'.

This means, when you create a CET for a Button Row you define and lock your settings for the base element and can open one modal popup for a button and define and lock your settings for a button of the button row.

These settings and locked values are used as base for all buttons you later add to a button row when using this CET on a page.

This theme option setting is a shortcut only. In backend an own CET for this subitem is created and managed. This allows to switch to select individual CET's for each subitem.

When this theme option is selected, hierarchical CET are not possible for elements with subitems.

"Individually select subitem custom element templates"


Added 2021-02-28

Extend the description for the last option to make it more clear.

"Individually select subitem custom element templates"

With this option selected you can use seperate subitem CET for each subitem. We will explain this using an ALB button row element.

Create the CET for the Button Row itself

Steps are similar as described for a button:

You need a buttonrow several times with the same buttons

You want to add buttons later

Now you must create your button row buttons, called button row item, for each styling you need:

mgmason commented 3 years ago

I recommend making these text changes, I also added some screenshots that may help with the explanation:

Basics

Using and working with a CET is similar to working with a normal ALB element, but there are a few things you need to know to understand the difference between the two so you can take full advantage of this powerful feature.

To follow this tutorial please use the following settings on WP Dashboard -> Theme Extensions -> Custom Elements:

Custom Elements Management: Editors and Admins
Custom Elements Locked Options: Show locked options to all users
Checkbox To Show Locked Options: Checked for all users
Checkbox Show advanced options: Check

CET_settings.jpg

Let us start our example with a simple ALB button element.

The Normal workflow would be:

You might face the following problems if you need more buttons:

This is the point were a CET can help greatly.

The standard ALB button has default settings that are predefined and preselected (we will focus on only a few to make it easier to follow):

Let's say, you want a specially designed button used several times on your site, it would help to have your settings already predefined. This is the first use of a CET:

CET_predefined_button.jpg

Important: A CET behaves like a normal ALB element but YOUR settings are predefined. For advanced users: the underlying shortcode attributes are modified for the element.

If in the future you want to change any of these settings:

When you now drag the CET on a page you have the new settings.

Important: All other already existing buttons on your page(s) remain unchanged !!! Only newly added buttons have the new settings.

In the real world you would like to maintain a consistent layout for your buttons across your site without the need to edit each button separately.

Lets say you must change the color for all your "Contact Me Button" buttons to red:

If you now reload the pages containing this element you will see that all the buttons have turned red (clear server cache if using a cache plugin and browser cache).

Important:

  • Locked values in a CET override any previous value of already existing elements on pages
  • Non locked values in a CET DO NOT change any previous value of already existing elements on pages
  • Locking/Unlocking a value in a CET DOES NOT make any changes to already existing elements on a page, the locked value replaces the original value on the fly on page load. For advanced users: the underlying shortcode attributes on pages are not modified, when executing the shortcode handler a check for locked values returns and replaces the attribute values from the page shortcode.

Locking depending settings:

Have a look at the button setting Button Colors Selection.

Depending on the selection the option Button Color is visible or not. If you want to make sure that the button color Red is used and cannot be changed you also must lock Button Colors Selection. Keep this in mind and be careful, as you cannot be sure what settings are set in the elements on all of the pages across your whole site.

The Customize Tab

This tab in a modal popup contains the option "Select a Custom Element to lock values". In our case open the modal popup of a button and you find in the dropdown:

CET_No_Custom_Element_used-all_options_available.jpg

On a page open the modal from:

It is possible to change the underlying Custom Element or switch to No Custom Element used, in either case the modal popup is reloaded to reflect the new situation for locked/unlocked values.

This means, if you have an existing page with an ALB button and want this button to have the locked values of a custom element you only need to select this custom element in the list. Another way is to select another custom element as a base for the page element and select the CET you wish.

CET_Another_way_is_to_select_another_custom_element_as_base_for_the_page_element_and_select_the_CET_you_wish.jpg

Important: changing the underlying template DOES NOT make any changes to the existing settings of the element on a page. This allows you to change and check the styling of an element without loosing your previously made settings when switching between them. For advanced users: the underlying shortcode attributes are not changed.

Custom Elements Advanced Option: Hierarchical Custom Elements

If this option is set to "Allow use of hierarchical custom elements" then a CET can be based on another CET. Then you can make your settings in the "Customize Tab" when editing a CET.

CET_Allow_use_of_hierarchical_custom_elements.jpg

This allows you to group settings and narrow down the options that can be changed.

Basically the same behavior as described above, only one big difference:

Important - this behavior is different to the one when used on a page:

When changing to another CET as base the settings of this underlying CET are set as new defaults in this CET - but are not copied when the underlying settings are changed later. When switching back to "No Custom Element used" the existing settings are NOT changed.

Lets have a look at an example, with our button element:

Lets say you need a fixed color for all buttons:

Create a CET button "Fixed Color" with color: Red. and lock

Create another CET button "Small":

When using the CET button "Small" on a page you find both color and size locked.

CET_When_using_the_CET_button-Small-on_a_page_you_find_both_color_and_size_locked.jpg

If you change the color to "Blue" in CET button "Fixed Color", the CET button "Small" on the page changes to blue in frontend. The CET button "Small" did not change the color setting RED.

CET_If_you_change_the_color_to_Blue_in_CET_button_Fixed_Color_the_CET_button_Small_on_the_page_changes_to_blue_in_frontend.jpg

Important: In case you change the hierarchy of CET: Locked values are checked from first parent up
( "Fixed Color" -> "Small" -> .... )

Custom Elements Advanced Option: Custom Elements For sub-items

It is also possible to use CET for elements which open another modal for sub-items like Button Row which has buttons (as Button Row Items).

By default the setting is: 'All sub-items use the same custom element template'.

With the default setting, when you create a CET for a Button Row and you define and lock your settings for the base element, and you can open one modal popup for a button and define and lock your settings for a button in the button row.

These settings and locked values are used as base for all buttons you later add to a button row when using this CET on a page.

CET_Custom_Elements_Advanced_Option_Custom_Elements_For_sub-items.jpg

This theme option setting is a shortcut only. In the backend a new CET for this subitem is created and managed. This allows you to select individual CET's for each subitem.

When this theme option is selected, hierarchical CET's are not possible for elements with sub-items.

"Individually select subitem custom element templates"

CET_in_the_selectbox-Select_a_Custom_Element_to_lock_values-in_the_modal_popup_for_subitems_you_find_all_available_CETs.jpg

mgmason commented 3 years ago

Update for last section

"Individually select subitem custom element templates"

CET_Individually_select_subitem_custom_element_templates.jpg

With this option selected you can use a seperate subitem CET, for each subitem used in the parent. We will explain this using an ALB Button Row element.

Create the CET for the Button Row itself

Steps are similar as described for a button:

If you want a Button Row used several times with the same buttons

If you want to add CET buttons to the Button Row later

CET_Button_Row-Customize_Custom_Button_Row-no_buttons.jpg

Now you must create a button for your Button Row, called a "Button Row Item":

CET_in_the_modal_popup_of_each_Button_Row_Item_select_the_CET_from_the_dropdown_in_the_Customize_Tab.jpg

Here the Button Row CET shows the "Button Row Item" CET

CET_Button_Row_shows_the_CET_from_the_Button_Row_Item.jpg

Please Note: A subitem CET, such as the "Button Row Item", will not show in the ALB Custom Elements block area, but it will be available within the parent element CET.

CET_A_subitem_CET_will_not_show_in_the_ALB_Custom_Elements_block_area_but_it_will_be_available_within_the_parent_element_CET.jpg