Skip to content

Commit 76211e2

Browse files
committed
Expand documentation for plugin elements
I had to source dive for this.
1 parent b106365 commit 76211e2

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

en/plugins.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,35 @@ you can do the following::
560560

561561
If the plugin prefix is omitted, the layout/view file will be located normally.
562562

563+
Plugin Elements
564+
---------------
565+
566+
To render an element from a plugin, use the :term:`plugin syntax` to reference
567+
a plugin. You do not need to use plugin syntax for elements in the current active plugin.
568+
569+
If the element doesn't exist in the plugin, it will look in the main APP
570+
folder::
571+
572+
echo $this->element('Contacts.helpbox');
573+
574+
If your view is a part of a plugin, you can omit the plugin name. For example,
575+
if you are in the ``ContactsController`` of the Contacts plugin, the following::
576+
577+
echo $this->element('helpbox');
578+
// and
579+
echo $this->element('Contacts.helpbox');
580+
581+
are equivalent and will result in the same element being rendered.
582+
583+
For elements inside subfolder of a plugin
584+
(for example, **plugins/Contacts/Template/element/sidebar/helpbox.php**), use the
585+
following::
586+
587+
echo $this->element('Contacts.sidebar/helpbox');
588+
563589
.. note::
590+
See :ref:`view-elements` for more information on rendering elements.
564591

565-
For information on how to use elements from a plugin, look up
566-
:ref:`view-elements`
567592

568593
Overriding Plugin Templates from Inside Your Application
569594
--------------------------------------------------------
@@ -579,6 +604,13 @@ Contacts controller you could make the following file::
579604
Creating this file would allow you to override
580605
**plugins/ContactManager/templates/Contacts/index.php**.
581606

607+
To override plugin elements, create an element with the same name in::
608+
609+
templates/plugin/ContactManager/element/helpbox.php
610+
611+
This file would override
612+
**plugins/ContactManager/tempaltes/element/helpbox.ctp**.
613+
582614
If your plugin is in a composer dependency (i.e. 'Company/ContactManager'), the
583615
path to the 'index' view of the Contacts controller will be::
584616

0 commit comments

Comments
 (0)