Page 1 of 1

[SOLVED] Problem with startExpandCollapse

Posted: Mon Oct 29, 2007 4:17 pm
by Milhaus
Hi,
in template for module I would like to have expandable/collapsable section. It is in foreach, so I am trying to supply unique id for every collapsable section through:

Code: Select all

{startExpandCollapse id='section{0|rand:100}' title='Zobrazit / Skrýt odpověď'}
<tr>
    <td colspan="2">{$entry->answer}</td>
  </tr>
{stopExpandCollapse}
It does not work and says:
Error: The expand/collapse plugin requires that both parameters (id,title) are used.' title='Zobrazit / Skrýt odpověď'}
If I remove {0|rand:100} part, it seems, that only problem is dual id (the error above doesn't appear). I tested random smarty plugin and it works properly.

What am I doing wrong?

Milhaus

Re: Problem with startExpandCollapse

Posted: Tue Oct 30, 2007 11:50 pm
by Milhaus
The solution is found (but it is not perfectly safe to use). Firstly make your copy of function.startExpandCollapse.php file.

In this copy, paste following to start of php part of file:

Code: Select all

srand(time());
Then find around line 27:

Code: Select all

$id = $params['id'];
and change it to:

Code: Select all

$id = (rand()%90000);
,where 90000 is higher border of random numbers interval (which in this case is 0-90000). The higher number you set, the more safe solution it will be (because it will be lower probability, that same numbers will be generated for more divs).

Re: [SOLVED] Problem with startExpandCollapse

Posted: Tue Sep 30, 2008 6:58 pm
by kendo451
You cannot use nested {} in a smarty call.