Contemplate Admin Page Alterations

rjl - March 17, 2007 - 13:50
Project:Content Templates (Contemplate)
Version:5.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

On the contemplate admin page where all node types are listed with the link to create or edit the templates, I have 2 suggestions:

1. It would be nice to see which templates (teaser, body, rss) have been altered. I have included some sample code below that would achieve the sort of result I am suggesting.

2. It would also be nice to be able to 'reset' a template from the admin page. I have (on more than one occaision) used PHP in my template with errors in my PHP code. Once the faulty PHP code is saved, I can no longer get to the 'edit' page (I get the error), so to 'reset' the template, it appears my only option is to go into the database table and delete the data. (Note: I could be wrong about this and maybe there is a way to 'reset' without having to go to the database, if so, please let me know.) I would have done some sample code for this, but the current 'reset' methodology doesn't use Drupal's confirm_form() functionality. So my suggestion would be to alter the 'reset' scheme to use Drupal's confirm_form() and then provide a link to it from the contemplate admin page.

Potential code changes for Suggestion 1 above

the contemplate_get_templates() function would need to include the 'flags' value in its returned array
*** = new lines of code

function contemplate_get_templates(){
  $result = db_query('SELECT * FROM {contemplate}');
  while($r = db_fetch_object($result)){
    $templates[$r->type]['teaser'] = $r->teaser;
    $templates[$r->type]['body'] = $r->body;
    $templates[$r->type]['rss'] = $r->rss;
    $templates[$r->type]['enclosure'] = $r->enclosure;
    *** $templates[$r->type]['flags'] = $r->flags;
  }
  return $templates;
}

the contemplate_admin() function would need to output 3 additional columns
*** = new lines of code

function contemplate_admin(){
  $types = node_get_types();
  $templates = contemplate_get_templates();
  foreach($types as $type){
    $rows[] = array(
      $type->name,
      *** CONTEMPLATE_TEASER_ENABLED & $templates[$type->type]['flags'] ? 'Yes' : 'No',
      *** CONTEMPLATE_BODY_ENABLED & $templates[$type->type]['flags'] ? 'Yes' : 'No',
      *** CONTEMPLATE_RSS_ENABLED & $templates[$type->type]['flags'] ? 'Yes' : 'No',
      l($templates[$type->type] ? t('edit template') : t('create template'), 'admin/content/templates/'. $type->type),
    );
  }
  $header = array(
    t('content type'),
    *** t('teaser'),
    *** t('body'),
    *** t('rss'),
    ''
  );
  $output .= theme("table", $header, $rows);
  $output .= contemplate_version();
  return $output;
}

#1

jrglasgow - May 13, 2008 - 02:03
Status:active» fixed

These changes have been implemented and committed and will appear in release 6.x-0.12 or later.

#2

Anonymous (not verified) - May 27, 2008 - 02:12
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.