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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:28:32+00:00 2026-06-05T18:28:32+00:00

Having php code: function getChildren($parent_id = 0) { …. return $SomeChildrenArray; } And Smarty

  • 0

Having php code:

function getChildren($parent_id = 0)
{
....
return $SomeChildrenArray;
}

And Smarty assignation $smarty->assign('children', getChildren($id));

How to write smarty expression to pass some value to the function?

  • 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-05T18:28:34+00:00Added an answer on June 5, 2026 at 6:28 pm

    Smarty can be extended through its plugins API. See registerPlugin() for an introduction.

    $smarty->registerPlugin('function', 'children', function($params, $template) {
      return "some string:" . $params['foobar'];
    });
    

    and

    {children foobar="hello world"}
    

    would output

    some string:hello world
    

    Note that plugin functions have to return a string.


    Since Smarty3 you can call and assign arbitrary functions from within a template:

    {$children = getChildren(3)}
    

    This way you can call any function and return any value/type you want. See Smarty_Security for details on how to control which functions may be called…

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

Sidebar

Related Questions

I'm having trouble getting some PHP code to work. Here is the function: function
I am having problems with the following code: function http_file_exists($url){ $f=fopen($url,r); if($f){ fclose($f); return
Hi im having problems with my PHP code for sending an email via a
I am having the strangest time with the following PHP code. The require_once runs
I am having a php file which executes some code to generate a html
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);
I'm having a problem with some code that used to work in PHP 4.X
I'm having a problem with a query prepared in PHP with PDO. The code:
I am having a link <a id=test href=text.php>test</a> I have the following jquery code
I often see this idiom when reading php code: public function __construct($config) { if

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.