January 12, 2017 at 2:35 am #1326892
What is the best recommended way to make custom elements?
Do we really need to use the four files of definition, shortcode, defaults.php and controls.php?
Or is it better that we use the “extends Cornerstone_element_base” way? like theme x did for the existing elements now?
I am curious what is the best way recommended for developers from the two ways?January 12, 2017 at 3:19 am #1326935
Thanks for writing in.
Yes, it’s important and it’s part of cornerstone standard. It makes code cleaner and properly grouped/ordered, and since cornerstone is using transients, it will be faster since cornerstone can call them by part.
Thanks!January 12, 2017 at 3:22 am #1326938
oke, because then I would ask if it would be possible to give some more information about the possibilities with the controls.
Because I find the examples too basic,
and it would be nice to have some explanation about how the ‘context’ option works like ‘context’ => ‘content’.
Because the explanation now about custom element misses a lot I think of crucial information to make nice custom elements?January 12, 2017 at 5:26 am #1327035
Yes, the examples are basic. It will be harder to follow if it’s too complex.
And about the context, it’s under the Mapping element control sections.
At this level of the control definition, you will also see context and suggest paired together. This is preparatory work in the API for an upcoming Cornerstone feature where users will be able to set the default values of element controls globally. If you set ‘context’ => ‘content’, you can prevent users from editing controls that may not make sense to have a global value for. suggest can be used to provide a default value in that case.
There will be an upcoming change in the cornerstone, maybe major changes and documentation may change as well. I understand it’s a bit crowded but we’ll improve it. For now, it only covers the basic one, and if you wish to dig deeper, you can find existing elements from cornerstone itself though its source files.
Though, you can stay for the basic for the meantime and you may open new thread if you run into some issues.