Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions ding_content_tema/ding_content_tema.module
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php
/**
* @file
* Tema site module main file.
*/

/**
* Implementation of hook_form_alter().
*/
function ding_content_tema_form_alter(&$form, $form_state, $form_id) {
// Fix some issus with the layout for static tema pages
// Fix some issus with the layout for static tema pages.
if ($form_id == 'static_tema_page_node_form') {
// Hide the comment settings form and disable comments.
unset($form['comment_settings']);
Expand All @@ -13,15 +17,16 @@ function ding_content_tema_form_alter(&$form, $form_state, $form_id) {
'#value' => 0,
);

// Set tema ref field to required (done here, so its only required on the node form).
// Set tema ref field to required (done here, so its only required
// on the node form).
if (isset($form['field_tema_ref'])) {
$form['field_tema_ref']['#required'] = TRUE;
}

// Don't display menu settings and attachments.
unset($form['attachments']);

// Hide the revision settings and never allow creating new versions
// Hide the revision settings and never allow creating new versions.
unset($form['revision_information']);
$form['revision'] = array(
'#type' => 'value',
Expand All @@ -38,7 +43,7 @@ function ding_content_tema_form_alter(&$form, $form_state, $form_id) {
function ding_content_tema_nodeapi(&$node, $op, $teaser, $page) {
if ($node->type == 'tema_site') {
if ($op == 'insert') {
// Create a menu for the newly create tema site
// Create a menu for the newly create tema site.
_ding_tema_menu($node, FALSE);
}
elseif ($op == 'update') {
Expand All @@ -54,21 +59,41 @@ function ding_content_tema_nodeapi(&$node, $op, $teaser, $page) {
elseif ($op == 'delete') {
// Delete the tema site menu and the associated links.
db_query("DELETE FROM {menu_links} WHERE menu_name = 'tema-site-%d'", array(
':nid' => $node->nid
':nid' => $node->nid,
));

db_query("DELETE FROM {menu_custom} WHERE menu_name = 'tema-site-%d'", array(
':nid' => $node->nid
':nid' => $node->nid,
));
}
}
}

/**
* Implements hook_views_pre_render().
*/
function ding_content_tema_views_pre_render(&$view) {
// When the event list is being displayed on a tema site page page...
if ($view->name == 'tema_sites' && $view->current_display == 'panel_pane_2') {
// Generate link to the tema site event page. This assumes that
// we're on the main event page, but this view is not displayed
// anywhere else at the moment, so it should be a fairly safe assumption.
$url = $_REQUEST['q'] . '/arrangementer';

// And overwrite the footer contents with it.
$view->display_handler->options['footer'] = l(t('More events'), $url, array(
'attributes' => array('class' => 'more-link'),
));
}
}

/**
* Helper function to create menu for them sites.
*
* @param $node
* @param $update
* @param stdClass $node
* Node object.
* @param boolean $update
* Update existing data or create new data.
*/
function _ding_tema_menu($node, $update = TRUE) {
$menu = array(
Expand All @@ -80,10 +105,10 @@ function _ding_tema_menu($node, $update = TRUE) {
drupal_write_record('menu_custom', $menu, array('menu_name'));
}
else {
// Create the main menu
// Create the main menu.
drupal_write_record('menu_custom', $menu);

// Add blog link
// Add blog link.
$item = array(
'menu_name' => $menu['menu_name'],
'link_title' => t('Blog'),
Expand All @@ -94,7 +119,7 @@ function _ding_tema_menu($node, $update = TRUE) {

menu_link_save($item);

// Add event link
// Add event link.
$item = array(
'menu_name' => $menu['menu_name'],
'link_title' => t('Events'),
Expand All @@ -118,6 +143,5 @@ function _ding_tema_menu($node, $update = TRUE) {
}
}

// Load the feature information
include_once('ding_content_tema.features.inc');

// Load the feature code.
include_once 'ding_content_tema.features.inc';
23 changes: 13 additions & 10 deletions ding_content_tema/ding_content_tema.views_default.inc
Original file line number Diff line number Diff line change
Expand Up @@ -737,22 +737,25 @@ function ding_content_tema_views_default_views() {
),
));
$handler->override_option('title', 'Arrangementer');
$handler->override_option('pane_title', 'Event list (frontpage)');
$handler->override_option('footer', 'Flere arrangementer');
$handler->override_option('footer_format', '1');
$handler->override_option('footer_empty', 0);
$handler->override_option('pane_title', 'Arrangementsliste');
$handler->override_option('pane_description', '');
$handler->override_option('pane_category', array(
'name' => 'Tema page',
'weight' => '0',
));
$handler->override_option('allow', array(
'use_pager' => FALSE,
'items_per_page' => FALSE,
'offset' => FALSE,
'link_to_view' => FALSE,
'more_link' => FALSE,
'path_override' => FALSE,
'title_override' => FALSE,
'exposed_form' => FALSE,
'fields_override' => FALSE,
'use_pager' => 0,
'items_per_page' => 0,
'offset' => 0,
'link_to_view' => 0,
'more_link' => 'more_link',
'path_override' => 0,
'title_override' => 0,
'exposed_form' => 0,
'fields_override' => 0,
));
$handler->override_option('argument_input', array(
'field_tema_ref_nid' => array(
Expand Down