Twitter
Tue
12
Aug
'08
PDF
Print
Send
 
Hits (18489) | Comments (111) | Favorited (15) | Votes (0)

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&amp; ?>

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']);

Comments
avatar
Quote
- -
Written by Maik Kaune on 13 August 2008

Though i am neither a real PHP coder nor a fulltime developer ;-) i see the difference and the usage. And it will take some time till i use this features...

If i understand it right, the previous solution gives also access to the field parameters?! And this field by field calls have to de done with the exact fieldname/title only?

1.) Can i retrieve the fieldnames automaticly? Cause this seems to be too hard-coded IMHO. And it can produce unwanted errors, caused by "typos" etc.

2.) Why can´t i retrieve the fields parameters? At least the label and the icon parameter should be available as well... 

Would be nice to have more information about the available variables and their usage!

TIA!!!

-
avatar
Quote
- -
Written by Maik Kaune on 13 August 2008

Sorry, forgot something...

3.) Why is it tied to a particular type? At the moment, i don´t understand this restriction... could you explain it more in detail?  

-
serhioromanoAvatar
Quote
- -
Written by serhioromano VIP on 14 August 2008

1) Automatic fetch of fields this is what right now all templates are using. They fetch fields in FOREACH cycle and display one by one according sort order and according parameters like icon and so on. But as this is different template style, which consider you know exactly which fields will be passed to this template and what information every field show, you may place icons in HTML directly with <img> tag. This answers 2) and 3)

 

-
vanniAvatar
Quote
- -
Written by vanni VIP on 20 August 2008

That's really pwerful.. but, what about joomla fields like author, date of creation,...?

-
serhioromanoAvatar
Quote
- -
Written by serhioromano VIP on 20 August 2008

This is an article core fields. And you can find in any template how to display them.

-
x102020Avatar
Quote
- -
Written by x102020 VIP on 07 September 2008

The above explination SHOULD be in the Documentation, this was the 1 section that seems to not be covered in the setup, and of course, it's really what makes your end result visible!

-
serhioromanoAvatar
Quote
- -
Written by serhioromano VIP on 18 September 2008

This is Documentation. But this is foe advanced users who know PHP and HTML. It is not regular. In manual explanation how to use standard templates.

-
elphilAvatar
Quote
- -
Written by elphil VIP on 08 October 2008

Hi, how can i use

<?php echo $this->ifields['Website'];?> in a foreach cycle? I always get the result of the first col.

-
serhioromanoAvatar
Quote
- -
Written by serhioromano VIP on 09 October 2008

But this will work only with Contetn v 1.3.9.1 or higher. I'll try to release new update next week.

-
brackishwatersAvatar
Quote
- -
Written by brackishwaters VIP on 12 November 2008

Hands down, this has become my number one tool Sergey!  I simply cannot wait to get my project into the hands of the owner because of the easy of use this compnent will give them and the layout capabilities and freedom you have given me as a designer.  

 

-
qwerty1Avatar
Quote
- -
Written by qwerty1 VIP on 12 November 2008

Hey Sergey,

Trying to acheive something similar to the look in the joomlaorg template:

< ?php echo $item->ctime->toFormat('%a'); ? >

using my datefield:

< ?php echo $this->ifields[$key]['Date:']; ? >

but trying:

< ?php echo $this->ifields[$key]['Date:']->toFormat('%a'); ? >

does not work, any suggestions would be greatly appreciate.

hs

-
avatar
Quote
- -
Written by Joe on 13 November 2008

Does the Override Function also work?

So that I can create a Folder com_resource/article/default_article.php in my html folder of my Template and customize it?

By this Way it could be possible to make fully featured Templates for Websites using Joomla & JoomSuite - so it would be REALLY useful.

Thanks in Advance

-
avatar
Quote
- -
Written by Joe on 13 November 2008

Ok, I couldn´t wait - so I just tried it out: It works

Simply copying the Files (not all, just .php & .xml) from components/com_resource/views/article/tmpl in templates/yourTemplate/html/com_resource/article

Now you´re be able to just override everything and by this way to integrate it into Templates (to sell/share)

The only Thing is that everybody needs different Fields, so if I would make a Template for Joomla, and would integrate override function for the JoomSuite Component, I should know which fields are getting used later - which is clearly impossible. 

A Solution could be a Configuration File which could be configured from the Admin BackEnd (like the Template Parameters). But not to configure various options - more to forward fields.

So if a User calls his "Imagefield" LOGO, and I (as the Template Designer) call it just IMAGE, the User can forward the content of his fields into the fields of my Template. Did you get me?

-
alyountAvatar
Quote
- -
Written by alyount VIP on 14 November 2008

I'm so excited about this new ability...well, new for me. If I would have known this before it would have saved me days of long, head pounding programming. Thank You, Thank You.

WOW!! this is cool.

-
SerhioAvatar
Quote
- -
Written by Serhio STAFF on 18 November 2008

@Joe
You cannot create template anywhere. It is not possible with Joomla MVC model. But you can create your own templates. In template manager you may copy any template with new name and edit it. Then on update you keep your custom template save

With this feature template overwriting not needed. You can simply create JoomSuite templates for list and article and distribute as separate installation package with templates. In core templates you may see who we handle unpredicteble number of fields of unexpected types.

-
CGenie.comAvatar
Quote
- -
Written by CGenie.com VIP on 26 November 2008

How do you create filters? I've clicked new under filters, however it asks for the field type and there's nothing in the dropdown?

-
avatar
Quote
- -
Written by Sandy on 01 December 2008

I am also having trouble with Filters.  There are no instructions to follow, so could someone please give some info on how to get these to work?

-
avatar
Quote
- -
Written by Samuel deHuszar Allen on 29 December 2008

Is there a way to restyle and insert these fields into a template?  What syntax would one use to call the field in one's template file?

-
kwoolfAvatar
Quote
- -
Written by kwoolf VIP on 06 January 2009

Any programmer out there willing to help make a custom template or two for JResources? I just want an easy way to select where to put a field. Wouldn't it be great if there was an AJAX template where you could just drag and drop fields into spaces that you can shrink and enlarge?

-
MarcelP102Avatar
Quote
- -
Written by MarcelP102 VIP on 09 January 2009

Wouldn't it be great if there was an AJAX template where you could just drag and drop fields into spaces that you can shrink and enlarge?

+1
Also looking for this.
Kevin Woolf, when you found someone that made a template for you, please say it in this treath because I'm also looking for some (paid) help

-
SerhioAvatar
Quote
- -
Written by Serhio STAFF on 12 January 2009

@Howard - date format.

ctime is a core record field and passed to templated prepared as date object. If you want to do the same with your type field you need first to make object of it.

$date = new JDate($this->ifields[$key]['Date:']);
echo $date->toFormat('%a');

@Samuel

You cannot insert it into template. This fields used only for inserting hiddem HTML meta tags. To format how it looks and where it is placed on the form you may editing form template.

@Kevin Woolf
@Marcel P

That would be great!

-
osotronAvatar
Quote
- -
Written by osotron VIP on 20 January 2009

Hi, I made an image field and shown it at intro. I want to make abailable to click over the image and access to article.

This is url http://www.redjif.org/red/index.php?option=com_resource&view=list&category_id=27&Itemid=115

I'm using a variation of default_subtmpl_default

Thanks for your help

-
SerhioAvatar
Quote
- -
Written by Serhio STAFF on 21 January 2009

You may use

echo $this->ifields[$key]->link;

To get link to article and insert to href atribute of tag (a) round image.

-
den2009Avatar
Quote
- -
Written by den2009 VIP on 24 January 2009

Link from a picture in list view:

a href="* echo $this->ifields[$key]->link; ** echo $this->ifields[$key]['Logo'];*   /a

is not workin. Other fields are working fine.

need to link to article

 

*is php

-
osotronAvatar
Quote
- -
Written by osotron VIP on 24 January 2009

I'll try and then tell you the result.

-
osotronAvatar
Quote
- -
Written by osotron VIP on 25 January 2009

Sorry but I am a newbie in php and its component. I could give further explanation. Deputy php by doubts.

I don't understand this means:

To get link to article and insert to href atribute of tag (a) round image.

-
avatar
Quote
- -
Written by Maik Kaune on 25 January 2009

Please, the whole topic is very interesting... but it needs more information and some examples, IMHO.

BTW, what about some new video tutorials ;-) TIA

-
yesewiAvatar
Quote
- -
Written by yesewi VIP on 01 February 2009

I read the article and all comments and did some test but I couldnt point an image as link I mean like this:

*a href="*?php echo $this->ifields['Indir']; ?*" * *img src="http://joomla.org/images/download.png"/* */a*

-
emakkiAvatar
Quote
- -
Written by emakki VIP on 04 February 2009

I am using this for a lyrics site and my client loves it. He wants in the list an image to show up if the record contains a youtube url. I tried to use an IF statement to show an image or to type "yes" but nothing worked. This will be helpful for others too I am sure.

Any help?

 Thanks

-
avatar
Quote
- -
Written by Tom K on 13 February 2009

I am trying to get tag cloud to do something but all I get is the header and no cloud. My artikels have tags and the type has Enable tags=yes. Why don't I get any cloud?

-

Page 1 of 4

Add New Comment
Name:
Email:
Comment:
Attachment
Hide Comment
Security code:
Enter text as you see on image
 
 
What is best way for Download/Installation MightyExtensions?
 


Member Area



Member Activity

We have 1895 guests and 9 members online


MightyTemplate - Professional Joomla Templates