1
Mazar
how can embed smarty loop inside a javascript array
  • 2009/8/1 10:59

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


var line=new Array()
<{foreach item=marq from=$marquee}>
<{counter start=1}>
line[<{counter}>]=<{$marq.title}>

<{/foreach}>

I am trying to do something like this

I am actually embeding javascript marquee into my one template file.
i need the above script to print something like this inside javascrpt array

line[1] = tile of the item
line[2] = tile of the item
and so on

Thanks in advance

2
ghia
Re: how can embed smarty loop inside a javascript array
  • 2009/8/1 11:37

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Your counter will be counting twice in every loop. Try:
var line=new Array()
<{foreach 
item=marq from=$marquee}>
  
line[<{counter start=1}>]=<a href="<{$xoops_url}>/modules/news/news.php?id=<{$marq.id}>&mod=<{$marq.tablename}>"><{$marq.title}>a>
<{/foreach}>

3
Mazar
Re: how can embed smarty loop inside a javascript array
  • 2009/8/3 6:58

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


This one printing line[1]=
line[1]=
it is not looping dont know why

4
ghia
Re: how can embed smarty loop inside a javascript array
  • 2009/8/3 10:03

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Which file are you adapting?
What is the version of the module?

5
bumciach
Re: how can embed smarty loop inside a javascript array
  • 2009/8/3 12:46

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


Are you using Multimenu? I have noticed this module cause counter problem. Try add before foreach
<{counter start=print=no assign=mycounter}>

and then
<{counter}>
line[<{mycounter}>]=...

Login

Who's Online

327 user(s) are online (190 user(s) are browsing Support Forums)


Members: 0


Guests: 327


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits