This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.php
99 lines (90 loc) · 3.7 KB
/
template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/*
*
* Project: PiratePartyUK Drupal Theme (NWP 2014)
*
*
* Authors: Andy Halsall <[email protected]>
* Peter Descard
* Pirate Party UK
* Date: 2014-02-24
* Version: 0.9
*
* Description: Theme settings template for the Pirate Party Drupal Theme
* Allows the setting of the front page teaserlinks in the theme settings
* TODO: Consider moving all the teaserlinks either into or out of the theme settings.
*
*
* Acknowledgements:
*
* Based on and developed from Piratenkleider - Wolfgang Wiese (xwolf)
* the current Piratenpartei wordpress theme (http://www.piratenkleider.de/)
*
*/
function pirateparty_preprocess_page(&$variables) {
$men = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
$variables['main_menu_expanded'] = $men;
}
function pirateparty_menu_tree__main_menu($variables) {
return '<ul id="menu-mainmenu" class="menu">' . $variables['tree'] . '</ul>';
}
function pirateparty_menu_link__main_menu(array $variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li>' . $output . $sub_menu . "</li>\n";
}
function pirateparty_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
$breadcrumb[] = '<span class="current">'. drupal_get_title() .'</span>';
if (!empty($breadcrumb)) {
$output = '<h2 class="skip">' . t('You are here') . '</h2>';
$output .= '<div class="breadcrumb">' . implode(' / ', $breadcrumb) . '</div>';
return $output;
}
}
function pirateparty_preprocess_node(&$vars, $hook) {
$account = user_load($vars['uid']);
$vars['user_signature'] = '';
if (isset($account->signature, $account->signature_format)) {
$vars['user_signature'] = check_markup($account->signature, $account->signature_format);
$vars['submitted'] = t('Written by !username on !datetime',
array(
'!username' => $vars['name'],
'!datetime' => $vars['date'],
));
}
}
function pirateparty_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['search_block_form']['#title'] = t('Search');
$form['search_block_form']['#title_display'] = 'invisible';
$form['search_block_form']['#size'] = 40;
$form['search_block_form']['#default_value'] = t('Search');
$form['actions']['#attributes']['class'][] = 'element-invisible';
$form['actions']['submit']['#value'] = t('GO!');
$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search';}";
$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search') {this.value = '';}";
$form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='Search'){ alert('Please enter a search'); return false; }";
$form['search_block_form']['#attributes']['placeholder'] = t('Search');
}
}
function pirateparty_process_page(&$vars){
$alias = explode('/',drupal_get_path_alias(request_uri()));
if($alias[1]== "campaigns") {
$vars['theme_hook_suggestions'][] = 'page__campaigns'; }
if($alias[1]== "policy") {
$vars['theme_hook_suggestions'][] = 'page__policy'; }
if($alias[1]== "leaders-office") {
$vars['theme_hook_suggestions'][] = 'page__leaders'; }
if($alias[1]== "press") {
$vars['theme_hook_suggestions'][] = 'page__press'; }
}
function pirateparty_preprocess_field(&$variables, $hook) {
if(($variables['element']['#field_type'] == 'text_long' || $variables['element']['#field_type'] == 'text_with_summary') && $variables['element']['#items'][0]['format'] == null) {
$variables['items'][0]['#markup'] = nl2br($variables['items'][0]['#markup']);
}
}