From 8056ee2e1324028c1f836cfc7ef7365dc7ed2582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Fri, 22 Jun 2012 09:48:53 +0200 Subject: [PATCH] Added option for setting heading tags surrounding node title on node title panes --- plugins/content_types/node_context/node_title.inc | 49 ++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/plugins/content_types/node_context/node_title.inc b/plugins/content_types/node_context/node_title.inc index 6a52306..bec8982 100644 --- a/plugins/content_types/node_context/node_title.inc +++ b/plugins/content_types/node_context/node_title.inc @@ -13,6 +13,9 @@ $plugin = array( 'category' => t('Node'), 'defaults' => array( 'link' => TRUE, + 'markup' => 'none', + 'id' => '', + 'class' => '', ), ); @@ -30,11 +33,27 @@ function ctools_node_title_content_type_render($subtype, $conf, $panel_args, $co // Load information about the node type. $type = node_type_get_type($node); + // Generate the title + $content = !empty($conf['link']) ? l($node->title, 'node/' . $node->nid) : check_plain($node->title); + + // Build any surrounding markup if so configured + if (isset($conf['markup']) && $conf['markup'] != 'none') { + $markup = '<' . $conf['markup']; + if (!empty($conf['id'])) { + $markup .= ' id="' . $conf['id'] . '"'; + } + if (!empty($conf['class'])) { + $markup .= ' class="' . $conf['class'] . '"'; + } + $markup .= '>' . $content . '' . "\n"; + $content = $markup; + } + // Build the content type block. $block = new stdClass(); $block->module = 'node_title'; $block->title = $type->title_label; - $block->content = !empty($conf['link']) ? l($node->title, 'node/' . $node->nid) : check_plain($node->title); + $block->content = $content; $block->delta = $node->nid; return $block; @@ -46,6 +65,34 @@ function ctools_node_title_content_type_render($subtype, $conf, $panel_args, $co function ctools_node_title_content_type_edit_form($form, &$form_state) { $conf = $form_state['conf']; + $form['markup'] = array( + '#title' => t('Title tag'), + '#type' => 'select', + '#options' => array( + 'none' => t('- No tag -'), + 'h1' => t('h1'), + 'h2' => t('h2'), + 'h3' => t('h3'), + 'h4' => t('h4'), + 'h5' => t('h5'), + 'h6' => t('h6'), + 'div' => t('div'), + ), + '#default_value' => $conf['markup'], + ); + + $form['id'] = array( + '#title' => t('CSS id to use'), + '#type' => 'textfield', + '#default_value' => $conf['id'], + ); + + $form['class'] = array( + '#title' => t('CSS class to use'), + '#type' => 'textfield', + '#default_value' => $conf['class'], + ); + $form['link'] = array( '#title' => t('Link to node'), '#type' => 'checkbox', -- 1.7.8.2+GitX