Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:21:13+00:00 2026-06-17T04:21:13+00:00

$_smarty_tpl->tpl_vars[‘Variable’]->value I wonder how smarty accesses objects. smarty_tpl is the object, but what is

  • 0
$_smarty_tpl->tpl_vars['Variable']->value

I wonder how smarty accesses objects. smarty_tpl is the object, but what is the property in the code example of a compiled tpl? Is it the array tpl_vars or value or a mixture of both?

In php, I create a smarty object and use it with methods (e.g. assign and display).
In the template itself (file .tpl) i do not use OOP, but a procedural style like in html.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:21:14+00:00Added an answer on June 17, 2026 at 4:21 am

    I have tried to make a small example, that will hopefully make this syntax clear to you:

    //A class that represents a fruit basket, a collection of fruits. Similar to $smarty, which is a collection of variables (among other things)
    class FruitBasket
    {
        public $basket = array();
    
        public function foo() {
    
        }
    }
    //A class that represents a fruit. It has some properties, like 'name' and 'color' 
    class Fruit
    {
        public $name = null;
        public $color = null;
    
        public function __construct($fruit_name) {
            $this->name = $fruit_name;
        }
    }
    
    $fruits = array();  //Make an array that will hold various fruits
    
    $fruit = new Fruit('banana');   //Create a fruit
    $fruit->color = 'yellow';       //Assign a value to its 'color' property 
    $fruits['banana'] = $fruit;     //Assign the fruit to the 'fruits' array
    
    //Make the same steps for 2 more fruits
    $fruit = new Fruit('apple');
    $fruit->color = 'red';
    $fruits['apple'] = $fruit;
    
    $fruit = new Fruit('pear');
    $fruit->color = 'green';
    $fruits['pear'] = $fruit;
    
    $fruit_basket = new FruitBasket(); //Create a new fruit basket
    $fruit_basket->basket = $fruits; //Assign the $fruits array to its 'basket' property
    
    echo $fruit_basket->basket['banana']->color;    //prints 'yellow'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Smarty templates which call object methods. I've put the code on a
i have a php variable which has html/smarty code in it $x='<a href={$link} >{$title}</a>';
How can i define variable not in PHP but in .TPL ? (smarty template
I use the smarty tpl. Now i have a php code and i want
This is my code inside smarty tpl file(or for any simple HTML): <img src=../images/blah.jpg
I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
I've been working with PHP for a while, but fairly new to Smarty. I'm
I am not quite sure about this, but reading from the smarty instructions http://www.smarty.net/docs/en/installing.smarty.basic.tpl
I am using the following code require 'Smarty/libs/Smarty.class.php'; $smarty = new Smarty; $sel=mysql_query(select id,
I have integrated the smarty template to my application as specified here But I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.