Dleshka.org
Авторизация

Хак Список меню в алфавитном порядке

-2
TipTop 12-04-2017 Хаки DLE 0 комментариев


Этот хак поможет Вам выводить список всех новостей в алфавитном порядке на вашем сайте.


Установка:

Открываем index.php и находим:

$tpl->load_template ( 'main.tpl' );


Ставим выше:

/*Меню алфавитное*/
	
$alfa_menu = dle_cache( "menu_for_main", $config['skin'], true );

if ($alfa_menu === FALSE) {
	$serials_alfa = Array();
	$cats = $db->query("SELECT id,date,title,category,alt_name FROM " . PREFIX . "_post ORDER BY title ASC");
	while ($row = $db->get_row($cats)) {
	
		if (ord(substr($row['title'], 0, 1)) >= 48 AND ord(substr($row['title'], 0, 1)) <= 57)
			$symbol = "0-9";
		elseif ((ord(strtoupper(substr($row['title'], 0, 1))) >= 65) AND (ord(strtoupper(substr($row['title'], 0, 1))) <= 90))
			$symbol = "A-Z";
		else
			$symbol = ord(substr($row['title'], 0, 1));
			
		$serials_alfa[$symbol][$row['id']] = $row;
	}

	$tpl1 = new dle_template();
	$tpl1->dir = TEMPLATE_DIR;
	$tpl1->load_template( 'menu_block.tpl' );

	foreach ($serials_alfa as $id => $array) {
		
		if ($id == '0-9' OR $id == 'A-Z')
			$tpl1->set("{symbol}", $id);
		else
			$tpl1->set("{symbol}", chr($id));
			
		$tpl1->set("{col}", count($array));
		
		$tpl12 = new dle_template();
		$tpl12->dir = TEMPLATE_DIR;
		$tpl12->load_template( 'menu_link.tpl' );
		
		foreach ($array as $key => $info) {

			$link = $config['http_home_url'] .$info['id']."-". $info['alt_name'] . ".html";
			
			$tpl12->set( '[full-link]', "<a href=\"" . $link . "\">" );
			$tpl12->set( '[/full-link]', "</a>" );	
			$tpl12->set( '{name}', $info['title'] );
			$tpl12->set( '{alt_name}', $info['metatitle'] );
			$tpl12->set( '{id}', $info['id'] );
			$tpl12->compile( 'menu_links' );			
			
		}
		
		$tpl1->set("{menu_links}", $tpl12->result['menu_links']); unset($tpl12);
		$tpl1->compile( 'alfa_menu' );
	}
	
	$alfa_menu = $tpl1->result['alfa_menu']; unset($tpl1);
	create_cache( "menu_for_main", $alfa_menu, $config['skin'], true );
	
}	
	$tpl->set("{menu}", $alfa_menu);


В шаблоне main.tpl подключаем:
{menu}


Alfavitnom.rar [5.64 Kb] (cкачиваний: 70)
Информация
Зарегистрируйтесь чтобы комментировать публикацию.
Авторизация