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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:13:41+00:00 2026-06-18T02:13:41+00:00

I have the following smarty structure (I’ve removed the unnecessary checks and visualisations): [4]

  • 0

I have the following smarty structure (I’ve removed the unnecessary checks and visualisations):

[4] {$vip_comments = array()}
{foreach from=$comments item=comment}
    {include file="layouts/comments_deepscan.htm" show_only=$comment.id vip_id=$comment.id}
{/foreach}
[3] {$vip_comments|print_r:true}

The comments_deepscan structure looks like this (I’ve removed the unnecessary checks and visualisations):

{foreach from=$comments item=comment}
    {if $comment.access_level == 5}
        [1] {$vip_comments[$vip_id] = true}
        [2] {$vip_comments|print_r:true}
        {break}
    {/if}
    {include file="layouts/comments_deepscan.htm" show_only=$comment.id vip_id=$vip_id}
{/foreach}

In some examples the [1] and [2] rows have been called, so $vip_comments looks like this:

Array ( [10446] => 1 )

However when the loops finish row [3] gives me an empty array. I think, that $vip_comments is not visible inside the deep scan loops, so it creates a new empty array and pushes the data inside.
I have tried to pass it as a reference like this (but it does not work):

{include file="layouts/comments_deepscan.htm" show_only=$comment.id vip_id=$comment.id vip_comments=&$vip_comments}

How to push elements inside the $vip_comments array on row [4]?

  • 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-18T02:13:42+00:00Added an answer on June 18, 2026 at 2:13 am

    You don’t say wich smarty version are you using, For smarty 3, try changing the scope of the included templates with “scope”

    {include file="layouts/comments_deepscan.htm" scope=parent ... }
    

    I will also take a look at {function}: http://www.smarty.net/docs/en/language.function.function.tpl, wich is a much better solution to what you’re trying to do.

    If you’re using smarty 2, I don’t think it can be done.

    However, note that smarty is a presentation oriented template system, and that (even if it can be done) it’s faster and preferable to do all this logic operations of processing data and creating arrays out of it in php.

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

Sidebar

Related Questions

I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
I have the following code in my smarty template: {foreach from=$categories item=l} <tr>----------START---------------</tr> <br/>
I have following code in a file with extension .tpl (Smarty template) {foreach from=$randomSites
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
Ok so I have an array that holds the following elements: $array['a']['b'][0]['c']; $array['a']['b'][1]['c']; $array['a']['d'][0]['c']['c'];
I have caching enabled on my smarty installation and have following Template Functions function
Let's say I have a smarty template file with the following content: <div> var
Following on closely from this Smart image search via Powershell I have the following
I have following codes using smarty template engine In php file: $smarty-&gt;assign('SITE_URL', 'http://localhost/mis/'); In
I have a Django application with the following directory structure /myapp/ /login/ /myapp_settings/ /subapp1/

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.