From 815ab94c707e13fbbeb173b681d32c6d65850128 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 26 May 2013 15:11:29 +0200 Subject: more docs on plugins --- doc/plugins.rst | 104 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/doc/plugins.rst b/doc/plugins.rst index 27c340f1d..76df7e071 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -6,63 +6,63 @@ General plugin infos -------------------- A plugin is in essence a seperate app. You should first read the `intro `_ and `tutorial `_ and create the basic files. -In addition to the basic structure you also want to make sure that the News app is enabled. To do that open :file:`appinfo/app.php` and add the following if: +In addition to the basic structure you also want to make sure that the News app is enabled. To do that open :file:`my_news_plugin/appinfo/app.php` and add the following if: .. code-block:: php - share(function ($c) { - // make the newscontainer available in your app - return new NewsContainer(); - }); + $this['NewsContainer'] = $this->share(function ($c) { + // make the newscontainer available in your app + return new NewsContainer(); + }); - $this['YourController'] = $this->share(function ($c) { - // use the feedbusinesslayer from the news app - // you can use all defined classes but its recommended that you - // stick to the mapper and businesslayer classes since they are less - // likely to change - return new YourController($c['NewsContainer']['FeedBusinessLayer']); - }); - } + $this['YourController'] = $this->share(function ($c) { + // use the feedbusinesslayer from the news app + // you can use all defined classes but its recommended that you + // stick to the mapper and businesslayer classes since they are less + // likely to change + return new YourController($c['NewsContainer']['FeedBusinessLayer']); + }); + } - - } + + } Using this method you can basically access all the functionality of the news app in your own app. @@ -72,39 +72,39 @@ A clientside plugin could either be a new interface for the news app or a script Custom script ~~~~~~~~~~~~~ -To add a simple script create the script in the :file:`js/script.js`, then use this inside your :file:`appinfo/app.php`: +To add a simple script create the script in the :file:`my_news_plugin/js/script.js`, then use this inside your :file:`my_news_plugin/appinfo/app.php`: .. code-block:: php + + addScript('script.js'); // add a script from js/script.js + $api = new API('my_news_plugin'); + $api->addScript('script.js'); // add a script from js/script.js - } + } Inside your script you have to make sure that the News app is active. You can do that by using: .. code-block:: js + + (function ($, angular, window, undefined) { - (function ($, angular, window, undefined) { - - var document = window.document; + var document = window.document; - $(document).ready(function () { - if ($('[ng-app="News"]').length > 0) { + $(document).ready(function () { + if ($('[ng-app="News"]').length > 0) { - // your code here + // your code here - } - }); + } + }); - })(jQuery, angular, window); + })(jQuery, angular, window); Custom User interface -- cgit v1.2.3