I'm attempting to create my first plugin! However, I want the user to be able to define a number that's then used in specific parts of the plugin. This plugin consists only of an xml file and a php file. How would I grab this specific parameter from the xml file that's submitted from the user, and then utilize it in the PHP?
Here's the XML below.
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="1.0.5" method="upgrade" group="content">
<name>Content - Article Title Truncator</name>
<creationDate>2016-01-16</creationDate>
<version>1.0.5</version>
<releaseDate>2016-01-16 07:08:00</releaseDate>
<releaseType>First public release!</releaseType>
<author>Michael Baas / Jesse Humphry</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://www.geeksgamers.com</authorUrl>
<copyright>(c) 2016 Jesse Humphry</copyright>
<description>This plugin has been adapted from a code publically released on
stackoverflow.com by Michael Baas in 2013. It has been adapted for
Joomla 3.x and given a back-end option for selection of character limit.
</description>
<files>
<filename plugin="Article Title Truncator">foo.php</filename>
</files>
<config>
<fields name="params">
<fieldset name="Basic">
<field name="Character Limit" type="text" default="25" filter="integer" maxlength="5" label="Character Limit">
</field>
</fieldset>
</fields>
</config>
</extension>
And here's the PHP file.
<?php
class plgContentFoo extends JPlugin
{
public function onContentPrepare($context,$article,$params,$limitstart)
{
$view = JRequest::getCmd('view');
$fp = in_array($view,array("featured","addmore"));
if ($fp && 34<strlen($article->title)) {
$article->title = trim(substr($article->title,0,31)) . "...";
return true;
}
}
}
?>
I need to get whatever is input from the XML form's "Character Limit" field and use it in place of the first integer in the PHP form. Now I'm new to all of this, so please be gentle.