Skip to content
Snippets Groups Projects
Commit 45174cac authored by Daniele Piaggesi's avatar Daniele Piaggesi
Browse files

fixed some bugs, managed LANGUAGE_NONE node types

parent 083a338b
No related branches found
Tags 7.x-1.0
No related merge requests found
......@@ -16,9 +16,21 @@ function prevnext_settings($form, &$form_state) {
'#default_value' => variable_get('prevnext_enabled_nodetypes', array())
);
$form['#submit'][] = 'prevnext_settings_submit';
return system_settings_form($form);
}
/**
* Previous/Next form settings submit
* Needs to clear cache :)
*
* @see prevnext_settings
*/
function prevnext_settings_submit(&$form, $form_state) {
drupal_flush_all_caches();
}
/**
* Helper: Retrieve all node types and create an option list with them.
*/
......@@ -30,6 +42,8 @@ function _prevnext_types_as_options() {
$options[$type] = $info->name;
}
asort($options);
return $options;
}
\ No newline at end of file
name = Previous Next
description = Add a "Previous/Next" variables to a node
core = 7.x
version = 7.x-1.0
\ No newline at end of file
version = 7.x-1.0
configure = admin/config/user-interface/prevnext
\ No newline at end of file
......@@ -45,9 +45,16 @@ function prevnext_node_view($node, $view_mode, $langcode) {
if (in_array($node->type, $enabled_nodetypes)) {
$extrafields = field_extra_fields_get_display('node', $node->type, $view_mode);
$language = NULL;
$prevnext = _prevnext_get_prevnext($node, $langcode);
if (module_enable(array('i18n_node'))) {
$mode = variable_get('language_content_type_' . $node->type, 0);
$language = ($mode != 0) ? $langcode : NULL;
}
$prevnext = _prevnext_get_prevnext($node, $language);
// @todo: Change theme() with a renderable array.
if (isset($extrafields['prevnext_previous']) && !empty($extrafields['prevnext_previous']['visible']) && !empty($prevnext['prev'])) {
$node->content['prevnext_previous'] = array(
'#markup' => theme('prevnext_previous', array(
......@@ -120,12 +127,15 @@ function prevnext_field_extra_fields() {
/**
* Helper: Retrieve previous/next nodes
*/
function _prevnext_get_prevnext($node, $language) {
function _prevnext_get_prevnext($node, $language = NULL) {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->propertyCondition('language', $language)
->propertyCondition('type', $node->type);
if (!is_null($language)) {
$query->propertyCondition('language', $language);
}
$result = $query->execute();
$nids = array();
......
<?php print $next ?>
\ No newline at end of file
<div id="prevnext-next" class="prevnext">
<?php print l(t('Next'), $next); ?>
</div>
\ No newline at end of file
<?php print $previous ?>
\ No newline at end of file
<div id="prevnext-previous" class="prevnext">
<?php print l(t('Previous'), $previous); ?>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment