Additional parameter to the material in Joomla 1.5

Sometimes, for automation, you need to add more material parameter, depending on which will display what you want. In this article I will tell you how it can be implemented.

So when you create a new material in the administrative panel on the right is the column “Parameters – Article,” “Options – Advanced” and “meta-data.” Depending on these parameters, you can separately adjust the output for each article. For the derivation of these parameters corresponds to the file \ administrator \ components \ com_content \ models \ article.xml. Consider it in more detail.

<Params addpath="/ Administrator / components / com_content / elements">

In this line path is added to the elements that uses the. More clearly it will be shown when parsing the following line.

<Param name="Created_by" type="Author" default="" label="Author" description="DETAILAUTHOR" />

Consider this line more:

  • name – the name of the parameter.
  • type – here in this line is just connects yelement (type = “author”) In this case, the file administrator \ components \ com_content \ elements \ author.php, which returns a list of all users. And when creating or editing the material you can put a journalist of any registered user. More information about the standard types (type), used in Joomla, you can read Joomla standard parameter_types.
  • default – default setting.
  • label – the parameter name, actually what you’ll see in the administrative panel of Joomla.
  • description – the description, the text that is displayed when you hover on a parameter.

Parameters can also be grouped, I’ll write more on this later.

So create an additional parameter and place it in a group of advanced, before heading out:

<Params group="Advanced">
  <Param name="You_param" type="List" default="" label="Your option description=Description of your setting>
    <Option value="0">Hide</ Option>
    <Option value="1">Show</ Option>
  </ Param>
  <Param name="Show_title" type="List" default="" label="Show Title" description="Show / Hide the items title">
    <Option value="">Use Global</ Option>
    <Option value="0">No</ Option>
    <Option value="1">Yes</ Option>
  </ Param>
...

In this case, I used type = “list”, you can also choose the style that suits you. Thus, the floor of the case is done, now it is added to the template output processing of this parameter.

Open the template file output material components \ com_content \ views \ article \ tmpl \ default.php and add to it (I chose to start):

<? Php / / No direct access
defined('_JEXEC') or die('Restricted access');

$ CanEdit  = ($ This->user->authorize('Com_content', 'Edit', 'Content', 'All') || $ This->user->authorize('Com_content', 'Edit', 'Content', 'Own'));
?>
<? Php if ($ This->params->get('You_param')) : ?> <! - Check whether the parameter ->
    <? Php echo  JText::_("Your option is included in this material '); ?> <! - A conclusion that we need ->
<? Php endif; ?> <! - End test ->

Output, in principle, can be anything – text, image, JavaScript, etc. etc.

If you want to display the value of this parameter, let you use type = “text”, then add the template output

<? Php if ($ This->params->get('You_param') !== '') : ?> <! - Check whether the parameter is empty ->
    <? Php echo  JText::_($ This->params->get('You_param')); ?> <! - Output value ->
<? Php endif; ?> <! - End test ->

That is, in principle, until all. Later I’ll write about the group and how to add parameters to a separate field in the table.

Comments are closed.