This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
documentation:create_first_plugin [2015/09/03 03:30] mooeditor |
documentation:create_first_plugin [2015/09/03 03:56] mooeditor [Create an element] |
||
---|---|---|---|
Line 687: | Line 687: | ||
Create new ctp file in **/app/Plugin/Note/View/Elements/myNotes.ctp** | Create new ctp file in **/app/Plugin/Note/View/Elements/myNotes.ctp** | ||
- | > New in version 2.2.1 | + | > New in version 2.2.1> Your ctp file must be place at /app/Plugin/{plugin_name}/View/Widgets/ instead of /app/Plugin/{plugin}/View/Elements/ |
- | > Your ctp file must be place at /app/Plugin/{plugin_name}/View/Widgets/ instead of /app/Plugin/{plugin}/View/Elements/ | + | |
<file php myNotes.ctp> | <file php myNotes.ctp> | ||
Line 766: | Line 765: | ||
<?php $this->Html->scriptEnd(); ?> | <?php $this->Html->scriptEnd(); ?> | ||
</file> | </file> | ||
+ | |||
+ | > New in version 2.2.1> | ||
+ | |||
+ | You don't have to use $this→requestAction() method to get the need variables anymore | ||
+ | |||
+ | e.g: <font 10.0ptline-height: 13.0pt;/arial;;#000000;;#ffffff><?php $notes = $this→requestAction(array('plugin' ⇒ 'Note', 'controller' ⇒ 'notes', 'action' ⇒ 'myNotes'), array('uri' ⇒ $this→here));?></font> | ||
+ | |||
+ | Instead, create a file in app/Plugin/{plugin_name}/Controller/Widgets/{your_element_name}Widget.php, for <font 10.0ptline-height: 13.0pt;font-family: Arial , Helvetica , FreeSans , sans-serif;/Arial , Helvetica , FreeSans , sans-serif;;#000000;;#ffffff>example:</font> <font 10.0ptline-height: 13.0pt;font-family: Arial , Helvetica , FreeSans , sans-serif;/Arial , Helvetica , FreeSans , sans-serif;;#000000;;#ffffff>app/Plugin/Note/Controller/Widgets/myNotesWidget.php</font> | ||
+ | |||
+ | with the content like the below code: | ||
+ | |||
+ | <code> | ||
+ | /* **myNotesWidget.ctp** */ | ||
+ | <?php | ||
+ | App::uses('Widget','Controller/Widgets'); | ||
+ | class MyNotesWidget extends Widget { | ||
+ | public function beforeRender(Controller $controller) { | ||
+ | $this->Note = MooCore::getInstance()->getModel('Note'); | ||
+ | $notes = $this->Note->find('all', array( | ||
+ | 'conditions' => array('uri' => $controller->request->here), | ||
+ | 'limit' => 1, | ||
+ | 'order' => array('Note.id' => 'DESC') | ||
+ | )); | ||
+ | $controller->set('notes',$notes); | ||
+ | } | ||
+ | </code> | ||
==== Create widget database ==== | ==== Create widget database ==== | ||
Line 1794: | Line 1819: | ||
<file php NoteHelper.php> | <file php NoteHelper.php> | ||
- | |||
//Tag system | //Tag system | ||
public function getTagUnionsNote($noteids) | public function getTagUnionsNote($noteids) |