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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:27:43+00:00 2026-06-06T22:27:43+00:00

I use the smarty tpl. Now i have a php code and i want

  • 0

I use the smarty tpl.

Now i have a php code and i want to use it in tpl:

Tis is the output from the array.

 stdClass Object
(
[Status] => success
[Time] => 2011-01-01 12:00:00
[IP] => 12.34.56.789
[Count] => 1
[Filter] => stdClass Object
    (
        [Sort] => ProductCode
        [Order] => DESC
        [Search] => 
        [ProductCode] => P001
        [ProductType] => 
    )

[Result] => stdClass Object
    (
        [Products] => Array
            (
                [0] => stdClass Object
                    (
                        [Identifier] => 1
                        [ProductCode] => test
                        [ProductName] => test
                    )

            )

    )

Tis is the php code that works:

   foreach ($product_list->Result->Products as $product) {
        echo $product->ProductName;
}

I use the follow tpl code but this doesn’t work

           //in php
    $smarty->assign("data", $product_list); 

     //in tpl file
    {foreach item=item from=$data}

<tr>
    <td align="center">{$item.Result->Products->ProductName}</td>
    <td align="center"></td>
    <td align="center"></td>
    <td align="center"><a href="" class="usuallink">{$header.order}</a></td>
</tr>
{/foreach}

Does anyone now how i can fix this?

  • 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-06T22:27:46+00:00Added an answer on June 6, 2026 at 10:27 pm

    Working code from php will look like this:

    {foreach from=$data->Result->Products item=item}
        {$item->ProductName}
    {/foreach}
    

    in smarty3 it can look even more like pure php:

    {foreach $data->Result->Products as $item}
        {$item->ProductName}
    {/foreach}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In smarty templates you can use raw PHP code in a template by placing
I am trying to use smarty variables inside javascript inside tpl {literal} <script language=javascript>
What function can I use in PHP for class Smarty which reads a variable's
I have a class that acts as a wrapper to Smarty but want to
We heavily use Smarty for all our front end templating. I have observed the
hi I am developing a module in oxid-esales . It use smarty templates. Now
So I want to use smarty similar to how asp.net does master pages, that
I use smarty template language in my php project. It works great except I'm
I have been out of PHP world for awhile, and now I am back.
NetBeans uses PHP Smarty Framework plugin for *.tpl files. Is it possible to change

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.