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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:35:59+00:00 2026-05-29T12:35:59+00:00

We have a social network startup and we need to integrate smarty templates. I

  • 0

We have a social network startup and we need to integrate smarty templates. I have a php array namely $profile_tasks . An element in $profile_tasks have the following properties ;

    [0] => Array
    (
        [name] => hello
        [location] => 
        [date] => 
        [time3] => 0
        [time1] => 
        [state] => 0
        [like_count] => 0
        [comment_count] => 2
        [does_id] => 91
        [comments] => Array
            (
                [sender_id] => 27
                [content] => khhkhjkkhk
                [time] => 2012-02-09 20:06:13
                [user_name] => aacanakin
                [picture_url] => http://graph.facebook.com/fb_user_name/picture
            )

    )

In my smarty template file, I have assigned the $profile_tasks array like this ;

$smarty->assign("profile_tasks", $profile_tasks);

In my .tpl file, there is no problem in printing any of the attributes like [name] or [location] fields. I have the following code for name printing ;

  {foreach name=outer item=profile_task from=$profile_tasks}  

    {$profile_task.name}
    {$profile_task.locatin} // these two works correctly

    {foreach name=inner item=comment from=$profile_task.comments}

      {comment.user_name} // these three statements doesn't return correct values
      {comment.picture_url}
      {comment.content}

    {/foreach}  

   {/foreach} 

So, as I stated before, the values inside comments array are not correct. What should I change in the inner loop ? Any help will be appreciated.

  • 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-29T12:36:00+00:00Added an answer on May 29, 2026 at 12:36 pm

    Just use

      {comments.user_name} // these three statements doesn't return correct values
      {comments.picture_url}
      {comments.content}
    

    you dont need

      {foreach name=inner item=comment from=$profile_task.comments}
    

    if your comments array had multiple sub arrays then you would.

    UPDATE:
    Update based on comment. Your array needs to look like this for your origional code to work

        [comments] => Array(
        [0] =>  Array
            (
                [sender_id] => 27
                [content] => khhkhjkkhk
                [time] => 2012-02-09 20:06:13
                [user_name] => aacanakin
                [picture_url] => http://graph.facebook.com/fb_user_name/picture
            )
       )
    

    PS. On a subnote, I very early on realised that using the default {} to denote smarty tags is really annoying as you cannot happily co-exist with javascript on a html template page. If you havn’t gone too far down the route I would use

    $left_delimiter -> '{[';
    $right_delimiter -> ']}';
    

    to specify an alternative. This means you dont have to worry about using the {literal} tags anywhere.

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

Sidebar

Related Questions

Currently, I am dealing with a social network startup. We use php & mysql
I have a social network similar to myspace but I use PHP and mysql,
On a social network I am working on in PHP/MySQL, I have a friends
I am working on a social network project in PHP/MySQL. If you have ever
I have a social network that I am making using php and mysql. I
I'm currently making my own social network and I have a php problem which
I have put together an ajax powered chat/social network with jquery, PHP - but
I have a social network type site (member site) I store a lot of
I have a jomsocial installation at http://social.drishtant.com/social-network-for-social-impact How can I embed the jomsocial component
I have chosen diploma work in university. It's a mini social network. But now

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.