I created new widget that generate sample data. For example:
ContactWidget
named widget makes contact template:
Plugin/ContactWidget/Widget/ContactWidget/skin/default.php
<?php $random_id = rand(100, 999); ?>
<div class="iconbox">
<h4>
<?php echo ipSlot('text', array('id' => 'contact_'.$random_id.'_title', 'default' => 'Title')); ?>
</h4>
<?php echo ipSlot('text', array('id' => 'contact_'.$random_id.'_desc', 'default' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pharetra, erat commodo fringilla consequat, urna velit ultrices orci, vel tincidunt risus ex in nisl.', 'tag' => 'p')); ?>
</div>
I used random() because of should be unique id. But when i refresh the page, missing all data.
How can i generate widget multiple instances with editable Slots
You are generating ID in skin. That means this id is being generated over again on each page-view.
The correct way would be to extend default widget controller class and override defaultData data method. This is the place to generate unique ID and return it in array of default data. Then you will be able to use that id in skin. Be aware that this is going to work only for new widgets.
How to extend that method: http://www.impresspages.org/docs/widgets (read PHP side section) http://www.impresspages.org/docs/class-ip-widgetcontroller (default widget controller class)