Пожалуйста, помогите решить следующую проблемку:
Использую модуль book для публикации книги, статей (страниц) в книге получается около сотни. Необходимо сортировать эти страницы. Статьи именуются не по алфавиту. Пытаюсь использовать "вес", но выбираются значения только от -15 до 15. Как можно увеличить этот диапазон? Или есть еще какой-нибудь способ сортировки?
Комментарии
Да, но придется изменить 2 системных файла.
Первый:
*** menu.inc 2011-08-03 09:06:53.000000000 +0200
--- menu.inc.mod 2011-08-18 14:56:42.000000000 +0200
***************
*** 828,838 ****
// Select the links from the table, and recursively build the tree. We
// LEFT JOIN since there is no match in {menu_router} for an external
// link.
$data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
! FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
WHERE ml.menu_name = '%s'". $where ."
! ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
$data['node_links'] = array();
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
--- 828,843 ----
// Select the links from the table, and recursively build the tree. We
// LEFT JOIN since there is no match in {menu_router} for an external
// link.
+ // $data['tree'] = menu_tree_data(db_query("
+ // SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
+ // FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
+ // WHERE ml.menu_name = '%s'". $where ."
+ // ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
$data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
! FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path LEFT JOIN {book} b ON ml.mlid = b.mlid LEFT JOIN {node} n ON b.nid = n.nid
WHERE ml.menu_name = '%s'". $where ."
! ORDER BY n.created", $args), $parents);
$data['node_links'] = array();
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
***************
*** 935,945 ****
// Select the links from the table, and recursively build the tree. We
// LEFT JOIN since there is no match in {menu_router} for an external
// link.
$data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
! ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
$data['node_links'] = array();
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
--- 940,955 ----
// Select the links from the table, and recursively build the tree. We
// LEFT JOIN since there is no match in {menu_router} for an external
// link.
+ // $data['tree'] = menu_tree_data(db_query("
+ // SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
+ // FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
+ // WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
+ // ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
$data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
! ORDER BY ml.weight ASC", $args), $parents);
$data['node_links'] = array();
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
***************
*** 1005,1011 ****
// Use db_rewrite_sql to evaluate view access without loading each full node.
$nids = array_keys($node_links);
$placeholders = '%d'. str_repeat(', %d', count($nids) - 1);
! $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (". $placeholders .")"), $nids);
while ($node = db_fetch_array($result)) {
$nid = $node['nid'];
foreach ($node_links[$nid] as $mlid => $link) {
--- 1015,1021 ----
// Use db_rewrite_sql to evaluate view access without loading each full node.
$nids = array_keys($node_links);
$placeholders = '%d'. str_repeat(', %d', count($nids) - 1);
! $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (". $placeholders .") ORDER BY n.created"), $nids);
while ($node = db_fetch_array($result)) {
$nid = $node['nid'];
foreach ($node_links[$nid] as $mlid => $link) {
***************
*** 1013,1018 ****
--- 1023,1029 ----
}
}
}
+ // ksort($tree);
_menu_tree_check_access($tree);
return;
}
***************
*** 1032,1042 ****
// The weights are made a uniform 5 digits by adding 50000 as an offset.
// After _menu_link_translate(), $item['title'] has the localized link title.
// Adding the mlid to the end of the index insures that it is unique.
! $new_tree[(50000 + $item['weight']) .' '. $item['title'] .' '. $item['mlid']] = $tree[$key];
}
}
// Sort siblings in the tree based on the weights and localized titles.
! ksort($new_tree);
$tree = $new_tree;
}
--- 1043,1053 ----
// The weights are made a uniform 5 digits by adding 50000 as an offset.
// After _menu_link_translate(), $item['title'] has the localized link title.
// Adding the mlid to the end of the index insures that it is unique.
! $new_tree[(50000 + $item['weight']) . $item['mlid']] = $tree[$key];
}
}
// Sort siblings in the tree based on the weights and localized titles.
! // ksort($new_tree);
$tree = $new_tree;
}
Второй:
*** book.module 2011-08-02 11:58:41.000000000 +0200
--- book.module.mod 2011-08-18 15:12:04.000000000 +0200
***************
*** 263,269 ****
$nids[] = $book['bid'];
}
if ($nids) {
! $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
while ($link = db_fetch_array($result2)) {
$link['href'] = $link['link_path'];
$link['options'] = unserialize($link['options']);
--- 263,269 ----
$nids[] = $book['bid'];
}
if ($nids) {
! $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, n.created"));
while ($link = db_fetch_array($result2)) {
$link['href'] = $link['link_path'];
$link['options'] = unserialize($link['options']);
***************
*** 385,391 ****
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $node->book['weight'],
! '#delta' => 15,
'#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);
--- 385,391 ----
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $node->book['weight'],
! '#delta' => 127,
'#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);
***************
*** 1069,1077 ****
$sql = "
SELECT b.*, m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
FROM {menu_links} ml INNER JOIN {menu_router} m ON m.path = ml.router_path
! INNER JOIN {book} b ON ml.mlid = b.mlid
WHERE ". implode(' AND ', $match) ."
! ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
$data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']);
$data['node_links'] = array();
--- 1069,1077 ----
$sql = "
SELECT b.*, m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
FROM {menu_links} ml INNER JOIN {menu_router} m ON m.path = ml.router_path
! INNER JOIN {book} b ON ml.mlid = b.mlid INNER JOIN {node} n ON b.nid = n.nid
WHERE ". implode(' AND ', $match) ."
! ORDER BY ml.weight, n.created";
$data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']);
$data['node_links'] = array();