home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (better-formats-defaults-admin-form.tpl.php)

This example Drupal source code file (better-formats-defaults-admin-form.tpl.php) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

data, div, endforeach, fieldset, foreach, id, order, php, rid, row, table, tbody, thead, tr

The better-formats-defaults-admin-form.tpl.php Drupal example source code

<?php

/**
 * @file
 * Default theme implementation to configure Better Formats defaults admin page.
 *
 * Available variables:
 * - $form_submit: Form submit button.
 *
 * Each $node_default_rows contains a row
 *
 * Each $data in $node_default_rows contains:
 * - $data->role: Role name.
 * - $data->format_select: Drop-down menu for setting format.
 * - $data->weight_select: Drop-down menu for setting weights.
 */
?>
<?php
  // Add table javascript
  drupal_add_tabledrag('node-format-defaults', 'order', 'sibling', 'better-formats-role-node-weight');
  drupal_add_tabledrag('comment-format-defaults', 'order', 'sibling', 'better-formats-role-comment-weight');
  drupal_add_tabledrag('block-format-defaults', 'order', 'sibling', 'better-formats-role-block-weight');
?>
<div class="description">
  <?php print '<p><strong>' . t('Defaults only affect NEW content NOT existing content.') . '</strong></p>'; ?>
  <?php print '<p><strong>' . t('Place roles in order of precedence by dragging more important roles to the top.') . '</strong></p>'; ?>
</div>
<fieldset>
  <legend><strong><?php print t('Node defaults'); ?></strong></legend>
  <table id="node-format-defaults">
    <thead>
      <tr>
        <th><?php print t('Role'); ?></th>
        <th><?php print t('Default format'); ?></th>
        <th><?php print t('Weight'); ?></th>
      </tr>
    </thead>
    <tbody>
      <?php $row = 0; ?>
      <?php foreach ($node_default_rows as $rid => $data): ?>
      <tr class="draggable <?php print $row % 2 ? 'odd' : 'even'; ?>">
        <td class=""><?php print $data->role; ?></td>
        <td><?php print $data->format_select; ?></td>
        <td><?php print $data->weight_select; ?></td>
      </tr>
      <?php $row++; ?>
      <?php endforeach; ?>
    </tbody>
  </table>
</fieldset>

<fieldset>
  <legend><strong><?php print t('Comment defaults'); ?></strong></legend>
  <table id="comment-format-defaults">
    <thead>
      <tr>
        <th><?php print t('Role'); ?></th>
        <th><?php print t('Default format'); ?></th>
        <th><?php print t('Weight'); ?></th>
      </tr>
    </thead>
    <tbody>
      <?php $row = 0; ?>
      <?php foreach ($comment_default_rows as $rid => $data): ?>
      <tr class="draggable <?php print $row % 2 ? 'odd' : 'even'; ?>">
        <td class=""><?php print $data->role; ?></td>
        <td><?php print $data->format_select; ?></td>
        <td><?php print $data->weight_select; ?></td>
      </tr>
      <?php $row++; ?>
      <?php endforeach; ?>
    </tbody>
  </table>
</fieldset>

<?php if ($_GET['q'] === 'admin/settings/filters/defaults'): ?>
<fieldset>
  <legend><strong><?php print t('Block defaults'); ?></strong></legend>
  <?php if (isset($block_default_rows)): ?>
    <table id="block-format-defaults">
      <thead>
        <tr>
          <th><?php print t('Role'); ?></th>
          <th><?php print t('Default format'); ?></th>
          <th><?php print t('Weight'); ?></th>
        </tr>
      </thead>
      <tbody>
        <?php $row = 0; ?>
        <?php foreach ($block_default_rows as $rid => $data): ?>
        <tr class="draggable <?php print $row % 2 ? 'odd' : 'even'; ?>">
          <td class=""><?php print $data->role; ?></td>
          <td><?php print $data->format_select; ?></td>
          <td><?php print $data->weight_select; ?></td>
        </tr>
        <?php $row++; ?>
        <?php endforeach; ?>
      </tbody>
    </table>
  <?php endif; ?>

</fieldset>
<?php endif; ?>

<div class="description">
  <?php print '<p>' . t('* Only formats that a role has permission to use are shown in the default format drop downs.') . '</p>'; ?>
</div>

<?php print $form_submit; ?>

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal better-formats-defaults-admin-form.tpl.php source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.