multiple droppable zones in 1 layout

Dear all,

I’m new to Yii and even to OOP…

I have a layout with draggables and 5 droppable zones on it. The only difference between these droppable zones is their ID. Since this design is everywhere in the application, I put these widgets in layouts/main.php.

This is the code (it works ok):




in main.php <body>

<?php

$this->beginWidget('zii.widgets.jui.CJuiDroppable', array(

    'options'=>array(

        'drop'=>"js:function( event, ui ){

                     var whoWasDragged = ui.draggable.attr('id');

                     var number =  1;

                     alert( 'item ' + whoWasDragged + ' at '+ number);

                 }",

        ),

    ));

echo '<ul><li>I am number 1</li></ul>';

$this->endWidget(); ?>

At this moment, I wrote this code 5 times in my layout, each with it’s own variable ‘number’. How can I reuse this code, while passing the variable number to it, so I only have to write this code once? If you can please also explain where I have to write which parts (MVC is new for me, too…)

Thanks in advance!