We added new variable to templates. It is called $this->ifields. This is an array with field name as array key and field value as array value. This improvement left no limitation to template formatting. If before you could only list additional fields in FOREACH cycle, now you can call every field individually.
But this has disadvantage also. Templates created with this style are not universal and can be used only for particular "article type" and hard to share.
Note. Before start working on your custom template, create copy in "Templates" sction in Resources admin panel.
It is needed that on update, you changes not to be lost. Also you should know that you need to copy from default template if only your custom template is table style. If you have blog or free style use other templates to copy from.
After you copy templates you can find it in
/joomla/components/com_resource/views/list/tmpl - for list, filter, category index templates
/joomla/components/com_resource/views/article/tmpl - for article, form, comments templates
/joomla/components/com_resource/views/rating - for rating templates
For example you created type with 3 fields.
Your Logotype - picture field
Description - html field
Website - url field
Then in template you may format it as folows
<table border="0"> <tr valign="top" width="100"> <td><?php echo $this->ifields['Your Logotype']; ?></td> <td><?php echo $this->ifields['Description']; ?><hr /> <?php echo JText::_('Website'); ?>: <?php echo $this->ifields['Website']; ?><td> </tr> </table>
This is an alternative to simple $this->fields variable that call field values including align table row parameter and show label or not.
In list templates you can access through $key of the record. When you cycle records array you catch the key of array and use it in ifields array
foreach($this->items AS $key => $item) { echo $this->ifields[$key]['Field name']; }
The same rule acts for form templates. You can use ifields variable to position form elements.
Also from version 1.4 you can get field value through standard $this->fields variable.
- In record list
<?php echo $this->fields[$item->id][23]->result ?>
where $item->id is an ID of the article in the foreach cycle and 23 is an ID of the field in field list of the ttype - In artilce layout
<?php echo $this->fields[23]->result& ?>
Some Ideas
- To get link to article use $item->link
<a href="<?php echo $item->link; ?>"><?php echo $this->ifields['Picture'] ?></a>
-
To check if record is featured use $item->featured (1 or 0)
if($item->featured) { echo "This Item Is Featured"; }
-
Tho check if record is new in list template or never viewed by visitor use $item->isNew. This may be used to mark article bold or attach picture "NEW"
- if youwhat to show field only if it contain value use
if(trim(strip_tags($this->ifields['Picture']))) { echo $this->ifields['Picture']; }
- To change Add to favorite or Bookmark icon put images with names favorite0.png and favorite1.png to CURRENT_TEMPLATE/images/
Debug Template
Sometimes people meet dificulties with template creation. So please be sure field parameters Show in intro, Show in Full should YES. Also it is good practice to ECHO variable value to know what is inside. But do not use ECHO. Use var_dump(). Because sometimes value contain HTML code which you do not see.
var_dump($this->ifields['Picture']);
on
on
on 
+1 (209) 800 1209