[SOLVED] Problem with startExpandCollapse

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Milhaus

[SOLVED] Problem with startExpandCollapse

Post 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
Last edited by Milhaus on Tue Oct 30, 2007 11:51 pm, edited 1 time in total.
Milhaus

Re: Problem with startExpandCollapse

Post 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).
kendo451

Re: [SOLVED] Problem with startExpandCollapse

Post by kendo451 »

You cannot use nested {} in a smarty call.
Locked

Return to “CMSMS Core”