Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem with complex variables

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Igel
Smarty Rookie


Joined: 21 Oct 2006
Posts: 5
Location: Zurich

PostPosted: Thu Sep 20, 2007 9:00 am    Post subject: Problem with complex variables Reply with quote

Hi folks

I came just up against a serious problem.

Since my page consists of different pages with completely the same layout but different content I decided to create only one template and display the content by reading it out of a database.
In the database there are tables like `news` (NwID, NwTitle) or `programm` (PrgrID, PrgrTitle). You see, all fields of the different tables have their specific prefix but a similiar name (prefix --> Nw, Prgr | name --> ID, Title).

Initial position:
Code:

$this->field_prefix = "Nw";
$this->field_arr['ID'] = $this->field_prefix."ID";
$this->field_arr['Title'] = $this->field_prefix."Title";
$smarty->assign("field_arr", $this->field_arr);

Additionally there's an array which contains the data of all records I want to display.

My problem now:
Code:

//Correct title information is shown
{$record_data[records].NwTitle}

//The following error message is thrown out
//Warning: Illegal offset type in C:\Programme\xampp\htdocs\zaunbau\smarty\templates_c\%%F2^F2A^F2A77DBB%%base_template.tmpl.html.php on line 146
{$record_data[records].$field_arr.Title}

//Output is NwTitle
{$field_arr.Title}


How can I achieve, that if {$record_data[records].$field_arr.Title} is written smarty interprets it as {$record_data[records].NwTitle}?

I'm grateful for every hint.

Greetz
Igel
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP