|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ubat Smarty n00b
Joined: 12 Aug 2003 Posts: 3
|
Posted: Tue Aug 12, 2003 11:54 pm Post subject: strange behavior of section |
|
|
Hi !
I am encountering a strange behavior of the section-tag. after months of working perfectly all of a sudden the section-tag would produce its output twice. i will give a simple excample, which behaves exactly the same as my original, complex array.
an array like
$myAr[] = "Hello";
$myAr[] = "Test";
$myAr[] = "One";
will show like
Hello
Test
One
Hello
Test
One
I am working on a rather complex system, so i can not tell all the circumstances in this thread, but may be someone had the same problem.
my section looks like that
{$section name=i loop=$myAr}
{$myAr[i]}<br>
{$/section}
best regards ! |
|
Back to top |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Wed Aug 13, 2003 6:49 am Post subject: |
|
|
Code: | {$section name=i loop=$myAr}
{$myAr[i]}<br>
{$/section} |
The code you posted is definitly wrong. It should look like this
Code: | {section name=i loop=$myAr}
{$myAr[i]}<br>
{/section} |
{section} ... {/section} is a block function. Therefore you shouldn't add a dollar sign ($) infront of the tag names. |
|
Back to top |
|
ubat Smarty n00b
Joined: 12 Aug 2003 Posts: 3
|
Posted: Wed Aug 13, 2003 5:41 pm Post subject: uhhh |
|
|
i am really sorry, but of course this is a typing mistake, as i was posting the thread in the middle of the night, wehen i had been coding for about 4 hours.
of course the syntax in my project is correct.
here ist my testcode from the project :
Code: |
$test[] = "Hallo";
$test[] = "Ein";
$test[] = "Test";
|
and here is my section
Code: |
{section name=i loop=$test}
{$test[i]}
{/section}
|
and here is my result :
Hallo Ein Test Hallo Ein Test
may be it helps to know, that i have a template with some kind of framework for the website, in which i include a variable content-template.
the section is then in the content-template. may be smarty mixes up something. but i really didnt have this problem before.
like
Code: |
<td>
{include file=$seitenInhalt}
</td>
|
where $seitenInhalt can be different .tpl-files, depending, how the variable was set by the calling php-script.
thanx |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Aug 13, 2003 5:57 pm Post subject: |
|
|
Hi ubat:
Yeah, I thought that it must have been a syntax error if it was working previously I thought I would wait to see how you responded to andre, though (hi andre).
Quick Q:
- what does a print_r($test) look like and/or what does the Smarty Debug Console say about $test's contents? or how about count($test) -- how many elements in the source array?
It almost looks like you are using a db abstraction layer that is returning both associative and indexed values (thereby duplicating all elements).
Quote: | after months of working perfectly all of a sudden the section-tag would produce its output twice |
What really happened to your code-base between the "working perfectly" and "all of a sudden"?
Clearly, the code you posted is not on its own responsible for the issue you are experiencing.
One last thing: the dynamic include in your last post--is that in a loop? |
|
Back to top |
|
ubat Smarty n00b
Joined: 12 Aug 2003 Posts: 3
|
Posted: Thu Aug 14, 2003 3:46 pm Post subject: |
|
|
hi again !
i finally found out, what caused the problem.
i was including my .php-file in another html-php-mixed file. because this was an old file ( not created by me - i don't like mixing html/php ), i commented the whole thing out and manipulated a copy of the content beneath the out-commented part.
of course php ignores the , so my file was included twice, once in the outcommented part and once in my working part, and as it was a pure php-file, it filled my arrays twice.
so this post is just to let everybody know of my blindness and that my problem is solved .
take care ! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|