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 1094237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:56:42+00:00 2026-05-16T23:56:42+00:00

I have the Smarty code {$obj->foo()->bar()} and Smarty complains about ‘unrecognized tag’ in the

  • 0

I have the Smarty code

{$obj->foo()->bar()}

and Smarty complains about ‘unrecognized tag’ in the expression. If I change it to just

{$obj->foo()}

it doesn’t complain, so I assume the problem is with the fact that I’m calling a method on the result of a method. Is this a limitation of Smarty’s parser, or am I missing something else here?

I know I can work around this with {assign}, I just wanted to know if I’d understood the extent of the limitations correctly.

  • 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-05-16T23:56:43+00:00Added an answer on May 16, 2026 at 11:56 pm

    Are you using Smarty2 or Smarty3?

    Smarty2 will require you to use {assign} after the first method. It will also have problems if you pass more than one argument to a method.

    Smarty3 has a completely rewritten parser and you can do exactly what you want. You also no longer need {assign}, as you can simply do {$new_var = "Anything"}.

    Here’s a test in Smarty3:

    Our classes

    class Foo {
        function boo() {
            return new Boo(); 
        }
    }
    
    class Boo {
        function woo() {
            return "woo!";
        }
    }
    

    Template variables assigned

    $foo = new Foo();
    $tpl->assign('foo', $foo);
    

    Template

    {$foo->boo()->woo()}
    

    Browser Output

    woo! 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an associative array assigned to a Smarty variable, something like this: $foo
I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
I'm using smarty CMS so for adding php code i have to edit index.inc.php
I'm using php with smarty. In php I have two arrays: $code = Array
I have the following code in my smarty template: {foreach from=$categories item=l} <tr>----------START---------------</tr> <br/>
I'm rewriting my code with smart pointer. I have such situation: void Foo(SomeClass *p)
i have a php variable which has html/smarty code in it $x='<a href={$link} >{$title}</a>';
I have the following code on my site (using php and smarty) to try
We have this Smarty function that returns HTML code for templates. However it is
How do you include Javascript from a CDN source using Smarty? We have code

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.