xml - First attempt php Joomla! plugin -


new php , plugin building. front end guy need learn templates building in joomla. have small 1 working gives ability insert , change text in function oncontentaftertitle.

class plgcontentmyplugin extends jplugin { public function oncontentaftertitle($context, $article, $params,  $limitstart)     {         if ($this->params->get('alt-text')) {             return $this->params->get('alt-text');         } else {             return "<p>hello world!</p>";         } 

now understanding xml determines backend options in admin control panel. using php display it.

i want able extend plugin, learning purposes. have xml displaying options change font colour , size. little unsure on php , function should calling in order achieve that. should using 1 of other parameters? e.g. $context or $article? appreciated.

<field name="font-size" type="list" default="12" description="what size font should message use?" label="font size">                 <option value="8">8px</option>                 <option value="12">12px</option>                  <option value="16">16px</option>             </field> 

again intention here expand php knowledge , able build templates other people can use. have worked out how assemble , hack template styling there totally acceptable not sure how end user need change , options need. require building on backend.

if understand correctly question, want add params plugin backend , use whatever represents in plugin output?

if so, first step add param xml, ie:

<field type="radio" name="isenabled" label="is enabled?" class="btn-group btn-group-yesno" default="1">                 <option value="1">jyes</option>                 <option value="0">jno</option>             </field> 

for params, fields sit inside "basic" fieldset. more on joomla field types: https://docs.joomla.org/standard_form_field_types

then, in plugin template file param in ever way want. in example use "isenabled" param in if statement:

if ($this->params->get("isenabled")) { ... } 

if used instead

echo $this->params->get("isenabled); 

i value param set in backend; in case, yes or no.

this applies modules.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -