Created
August 30, 2010 20:55
-
-
Save zerolab/558036 to your computer and use it in GitHub Desktop.
Fixes the Drupal 5 + Paging 5.x-1.2 and missing CCK fields (http://drupal.org/node/286260)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- paging.module 2009-01-23 23:53:18.000000000 +0000 | |
+++ paging.module 2010-08-30 21:26:41.081673004 +0100 | |
@@ -242,14 +242,63 @@ function _paging_nodeapi(&$node, &$node_ | |
$node->body = check_markup($node->pages[$page], $node->format, false); | |
$position = variable_get('paging_pager_widget_position', 'below'); | |
$node->paging = theme('pager', NULL, 1, $element); | |
+ | |
+ // Remove internal <!--paging_filter--> tag from final output. | |
+ $node->body = str_replace('<!--paging_filter-->', '', $node->body); | |
+ | |
+ // Fux the dissapearing CCK fields | |
+ // Sort node content fields by weight | |
+ if (!isset($node->content['#sorted'])) { | |
+ uasort($node->content, "_element_sort"); | |
+ } | |
+ | |
+ $node->content['#sorted'] = true; | |
+ | |
+ $before_body = true; | |
+ $first_page = ($page == 0); | |
+ $last_page = ($page == ($node->page_count - 1)); | |
+ | |
+ foreach (array_keys($node->content) as $field) { | |
+ if (is_array($node->content[$field]) && | |
+ (strpos($field, 'field_') !== FALSE || $field == 'body')) { | |
+ if ($field == 'body') { | |
+ $before_body = false; | |
+ } | |
+ // If not on the first page, hide fields lighter than the body | |
+ elseif ($before_body) { | |
+ if ($first_page) { | |
+ // show only if allowed to | |
+ if ($node->content[$field]['#access']) { | |
+ // imagefields would not be reformatted, so show its 'view' | |
+ $field_content = isset($node->{$field}[0]['view']) ? $node->{$field}[0]['view'] : content_format($field, $node->{$field}); | |
+ $node->body = $field_content . $node->body; | |
+ } | |
+ } | |
+ else { | |
+ $node->content[$field]['#access'] = false; | |
+ } | |
+ } | |
+ // If not on the last page, hide fields heavier than the body | |
+ elseif (!$before_body) { | |
+ if (!$last_page) { | |
+ $node->content[$field]['#access'] = false; | |
+ } | |
+ // show only if allowed to | |
+ else if ($node->content[$field]['#access']) { | |
+ $field_content = isset($node->{$field}[0]['view']) ? $node->{$field}[0]['view'] : content_format($field, $node->{$field}); | |
+ $node->body .= $field_content; | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
+ // finally add the pager | |
if ($position == 'above' || $position == 'both') { | |
$node->body = $node->paging . $node->body; | |
} | |
if ($position == 'below' || $position == 'both') { | |
$node->body .= $node->paging; | |
} | |
- // Remove internal <!--paging_filter--> tag from final output. | |
- $node->body = str_replace('<!--paging_filter-->', '', $node->body); | |
} | |
} | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment