You are here

layouter_extension_example.module in Layouter - WYSIWYG layout templates 7

Extension example.

File

modules/layouter_extension_example/layouter_extension_example.module
View source
<?php

/**
 * @file
 * Extension example.
 */

/**
 * Implements hook_form_alter().
 */
function layouter_extension_example_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'layouter_choose_layout_form') {
    $form['#attached']['css'][] = drupal_get_path('module', 'layouter_extension_example') . '/theme/layouter_extension_example.css';
  }
}

/**
 * Implements hook_layouter_templates().
 */
function layouter_extension_example_layouter_templates() {
  $items = array(
    'one_column_width_500' => array(
      'title' => t('Single column of text 500px wide'),
      'form' => 'layouter_extension_example_one_column_width_500_form',
      'theme' => 'layouter_extension_example_one_column_width_500',
    ),
  );
  return $items;
}

/**
 * Implements hook_theme().
 */
function layouter_extension_example_theme($existing, $type, $theme, $path) {
  return array(
    'layouter_extension_example_one_column_width_500' => array(
      'variables' => array(
        'text' => NULL,
      ),
      'template' => 'theme/tpl/one_column_width_500',
    ),
  );
}

/**
 * Form for adding content for one_column_width_500 layout.
 */
function layouter_extension_example_one_column_width_500_form($form, &$form_state) {
  $form_state['title'] = $form_state['form_info']['forms'][$form_state['step']]['form title'];
  $form['text_content'] = array(
    '#type' => 'textarea',
    '#title' => t('Text'),
    '#rows' => 15,
    '#required' => 1,
  );
  return $form;
}

/**
 * Submit handler for one_column_width_500 form.
 */
function layouter_extension_example_one_column_width_500_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $text_content = strip_tags($values['text_content']);
  $textarea_id = $form_state['textarea_id'];

  // Apply the layout to the content.
  $content = theme('layouter_extension_example_one_column_width_500', array(
    'text' => $text_content,
  ));

  // Insert it into textarea field.
  layouter_insert_content_into_textarea($textarea_id, $content);
}

Functions

Namesort descending Description
layouter_extension_example_form_alter Implements hook_form_alter().
layouter_extension_example_layouter_templates Implements hook_layouter_templates().
layouter_extension_example_one_column_width_500_form Form for adding content for one_column_width_500 layout.
layouter_extension_example_one_column_width_500_form_submit Submit handler for one_column_width_500 form.
layouter_extension_example_theme Implements hook_theme().