Last active
December 26, 2015 12:29
-
-
Save LeoOnTheEarth/7152018 to your computer and use it in GitHub Desktop.
Joomla! plugin example code
Put these files into "plugin/system/sms" folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class plgSystemSms extends JPlugin | |
{ | |
/* | |
* onAfterInitialise | |
* onAfterRoute | |
* onAfterDispatch | |
* onAfterRender | |
*/ | |
public function onAfterRender() | |
{ | |
$app = JFactory::getApplication(); | |
if ($app->isAdmin()) | |
{ | |
return; | |
} | |
$param = $this->params->get('a_foo_param', 'default_value'); | |
$body = JResponse::getBody(); | |
JResponse::setBody('$param:' . $param . $body); | |
//jexit('<pre>'.$body.'</pre>'); | |
} | |
public function onAfterDispatch() | |
{ | |
$doc = JFactory::getDocument(); | |
$doc->addStyleSheet('system/sms/a.css'); | |
$doc->addScript('system/sms/a.js'); | |
$script = <<<JS | |
var nodeTest = document.getElementById('test'); | |
JS; | |
$doc->addScriptDeclaration($script); | |
//var_dump($doc->_styleSheets); | |
//var_dump($doc->_scripts); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<extension version="3.1" type="plugin" group="content"> | |
<name>plg_system_sms</name> | |
<config> | |
<fields name="params"> | |
<fieldset name="basic"> | |
<field | |
name="a_foo_param" | |
type="text" | |
label="Foo" | |
description="這是描述" | |
default="烏拉阿拉~~~" | |
/> | |
<field | |
name="another_param" | |
type="list" | |
label="清單" | |
description="清單爹盟" | |
default="1" | |
> | |
<option value="0">???</option> | |
<option value="1">???</option> | |
<option value="2">????</option> | |
</field> | |
<field | |
name="another_param2" | |
type="radio" | |
label="清單2" | |
description="清單爹盟2" | |
default="2" | |
> | |
<option value="0">車馬炮</option> | |
<option value="1">將士象</option> | |
<option value="2">無名小卒</option> | |
</field> | |
</fieldset> | |
<fieldset name="advanced"> | |
</fieldset> | |
<fieldset name="foo"> | |
</fieldset> | |
</fields> | |
</config> | |
</extension> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment