ullCms Static Content Blocks

Here is a short tutorial on how to use static content blocks.

A content block is an editable area containing text and image(s).

We'll create a content block containing one text field and one image field.
Let's call it "text-image".

Configure the content block

You can skip this step, if you do not need any special configuration like custom data fields etc

  • Go to apps/frontend/lib/generator/columnConfigCollection/
  • Create a new columnsConfig for your blocktype, eg, copy UllCmsContentBlockColumnConfigCollection.class.php
  • Name it UllCmsContentBlockTextImageColumnConfigCollection.class.php
  • class UllCmsContentBlockTextImageColumnConfigCollection extends UllCmsContentBlockColumnConfigCollection
    {
     
      protected function applyCustomSettings()
      {
        parent::applyCustomSettings();
          
        $this->disableAllExceptCommonHiddenAnd(array(
          'body',
          'image',
          'parent_ull_cms_item_id',
          'is_active',
        ));
      
        $this['image']
          ->setMetaWidgetClassName('ullMetaWidgetGallery')
          ->setLabel(__('Image', null, 'ullCmsMessages'))
          ->setOption('image_width', 192)
          ->setOption('generate_thumbnails', false)
          ->setOption('single', true) 
          ->setHelp('Automatically scaled to 192px width')  
        ;     
      }   
    }
  • Publish the new class to the production site
    • php symfony ullright:publish --only-files

Set up the database

  • Go to the live site
  • Create the entry for the content type:
  • Create the content block itself
    • Admin Sidebar -> Manage Content -> Manage Content Blocks
      (http://www.example.com/ullCmsContentBlock/list)
    • Create a new entry
    • Select our new content block type "TextImage"
    • Enter some text and upload an image
    • Parent item: select the main page on which this content block will be embedded
    • Unique name / slug: my-content-block1

Render the content block

Go back to eclipse and open the template where you want to render the content block

  • e.g. apps/frontend/modules/ullCms/templates/homepageSuccess.php
  • Add the following code
    • ...
        <div id="my_content_block1">
          <?php $content_block = UllCmsContentBlockTable::findOneBySlug('my-content-block1') ?>
          <?php include_component('ullCms', 'editLink', array('doc' => $content_block)) ?>
          <?php echo image_tag($content_block->image) ?>
          <?php echo auto_link_text($content_block->body, $link = 'all', array(
                'class'  => 'link_external',
                'target' => '_blank',
          )) ?> 
        </div>
      ...

You're done!

When you logged in with admin rights, you can now edit the content block by clicking on the pen icon next to it.