Skip to content

Commit

Permalink
[ENH] Add example of wiki-plugin style views in use
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonko committed Feb 4, 2015
1 parent 57be160 commit 6f04aef
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions profiles/02_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ objects:
type: wiki_page
ref: page_about
data:
mode: create
name: About Tiki Addons
mode: create_or_update
name: About Tiki Addons
content: wikicontent:page_about
description:
2 changes: 1 addition & 1 deletion profiles/02_content/page_about.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Tiki Addons is a way to deploy custom "apps" or other addons to Tiki. It support
*Language Files
*PHP Code in libs and views
!Example of View
{addon package="tikiorg/helloworld" view="helloworld"}
{addon package="tikiorg/helloworld" view="helloworld" color="green"}
2 changes: 1 addition & 1 deletion templates/tikiorg-helloworld.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<h2>{tr}Is it working?{/tr}</h2>
<h2 {if isset($color)}style="color: {$color|escape};"{/if}>{tr}Is it working?{/tr}</h2>
<p>{if $prefs.ta_tikiorg_helloworld_boldtext == 'y'}<b>{/if}{$bar|escape}{if $prefs.ta_tikiorg_helloworld_boldtext == 'y'}</b>{/if}</p>
</div>
2 changes: 1 addition & 1 deletion tikiaddon.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Hello World",
"package": "tikiorg/helloworld",
"version": "0.1",
"version": "0.1.1",
"url": "http://dev.tiki.org/TikiAddonHelloWorld",
"smarty": true,
"tiki": ["14"],
Expand Down
5 changes: 5 additions & 0 deletions upgrade.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
{
"0.1": {
"remove": [],
"forget": ["02_content"],
"reapply": []
}
}
22 changes: 22 additions & 0 deletions views/helloworld.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

namespace tikiaddon\tikiorg\helloworld;

function helloworld_info()
{
return array(
'name' => tra('Print Hello World'),
'description' => tra('Display output of a Tiki Addon View'),
'filter' => 'text',
'params' => array(
'color' => array(
'required' => false,
'name' => tra('Color of introductory text'),
'description' => tra('The color to display the introductory text in'),
'extraparams' => false,
'filter' => 'text',
),
),
);
}

function helloworld($data, $params)
{
// extracts parameters passed from wikiplugin_addon.php
Expand All @@ -12,6 +30,10 @@ function helloworld($data, $params)

$foo = $helloworld->lib('foo');

if (!empty($color)) {
$helloworld->smarty->assign('color', $color);
}

// Warning: the following lines use the Tiki global smarty object,
// which is *bad* practice as it can cause variables to be overwritten.
// \TikiLib::lib('smarty')->assign('bar', $foo->hello());
Expand Down

0 comments on commit 6f04aef

Please # to comment.