By: Maz
Date: 2005-10-29
Time: 13:08
|
Reading Class Vars
I have:
/*-----------------------------------------------------------------
* Retrieve record for a skin id
*-----------------------------------------------------------------
* @param int $id The id of the skin to check
* @return arr $skin_rec Skin record field values
*---------------------------------------------------------------*/
function get_skin_details($id)
{
$query = " SELECT skin_name, skin_version
FROM ".INV_PREFIX."skins
WHERE skin_id = $id";
$this->skin_rec = $this->db->get_row($query);
} |
Which works fine and returns:
stdClass Object
(
[skin_name] => Test
[skin_version] => 2.3
) |
My somewhat stupid question is how do I then display those values in the template?
Do I have to assign as somethign like $rst = $SKIN->skin_rec; and then use[var.rst.skin_name] or can I reference the class array values directly? Something like [var.skin.skin_name]?
Sorry, I'm sure I've seen this answered somewhere before but I'm damned if I can find it.
|
By: Maz
Date: 2005-10-29
Time: 13:09
|
Re: Reading Class Vars
Whoops, I meant:
something like [var.skin_rec.skin_name] |
|
By: Skrol29
Date: 2005-10-29
Time: 19:14
|
Re: Reading Class Vars
Hello,
You could use a special function to use with a parameter "onformat", but this means the function will be call each time a TBS Field needs it.
If you want to display "skin_name" and "skin_version" then the sql query will be lunched two times.
To circumvent this problem the fnuction can store the result into a global variable.
|
By: Anonymous
Date: 2005-10-29
Time: 19:28
|
Re: Reading Class Vars
Yeah, thanks. I had a play with it after I posted and figured it was just easier to assign it as:
$view = $objSkin->skin_rec;
$TBS->Show(); |
and then just use [var.view.skin_name], etc. That's another reason why I love TBS - there's always a solution!
|
|
Posting in progress.
Please wait...
|