Documentation 1.x

How to create custom widget layout

To add new widget layout, you need to override widget configuration.php and template.php files. We will use widget "separator" as an example and add new layout "custom" to it. In the same way you can add any number of layouts to all widgets.

Step 1 / 2 - override widget configuration file

Copy file config.php from ip_cms/modules/standard/content_management/widgets/text_photos/separator/ to ip_configs/standard/content_management/widgets/text_photos/separator/.

Add new line:

<?php
$layouts[] = array('translation'=>'Custom', 'name'=>'custom');
?>

Now you should see new layout in layout select box.

Layout selection on ImpressPages CMS

Step 2 / 2 - customize template

Now we need to customize the look of new layout. Duplicate template.php file from ip_cms/modules/standard/content_management/widgets/text_photos/separator/ to ip_themes/ip_default/modules/standard/content_management/widgets/text_photos/separator/.

Modify your new template.php file to support new layout. Add these lines to your new template.php file:

<?php
case "custom":
  return "\n".'<div class="ipWidget ipWidgetSeparator ipWidgetSeparatorCustom">---Custom HTML---</div>'."\n";
break;
?>
Custom widget layout preview

If you change something in ip_themes/ip_default/modules/standard/content_management/widgets/text_photos/separator/template.php your changes will be visible on public website after you clear the cache or resave the page.

Download complete exmample

Write a comment

You must be logged in to comment.