Все для DataLife Engine / DLE хаки / Хак для DLE / Хак для DLE Обновляем хлебные крошки

Хак для DLE Обновляем хлебные крошки


Представляем хак для DLE обновляем хлебные крошки RDFA Breadcrumb по примеру Google, они являются навигационной цепочки (дублирующее меню, по названию «хлебные крошки», англ. Breadcrumbs) — это элемент навигации (чаще всего в файловых менеджерах).

Установка хака DLE 10.2 - 11.x обновление хлебных крошек:

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

if ($config['speedbar'] AND !$view_template ) {
	
	$s_navigation = "<span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"{$config['http_home_url']}\" itemprop=\"url\"><span itemprop=\"title\">" . $config['short_title'] . "</span></a></span>";

	if( $config['start_site'] == 3 AND $_SERVER['QUERY_STRING'] == "" AND !$_POST['do']) $titl_e = "";

	if (intval($category_id)) $s_navigation .= " {$config['speedbar_separator']} " . get_breadcrumbcategories ( intval($category_id), $config['speedbar_separator'] );
	elseif ($do == 'tags') {
		
		if ($config['allow_alt_url']) $s_navigation .= " {$config['speedbar_separator']} <span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"" . $config['http_home_url'] . "tags/\" itemprop=\"url\"><span itemprop=\"title\">" . $lang['tag_cloud'] . "</span></a></span> {$config['speedbar_separator']} " . $tag;
		else $s_navigation .= " {$config['speedbar_separator']} <span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"?do=tags\" itemprop=\"url\"><span itemprop=\"title\">" . $lang['tag_cloud'] . "</span></a></span> {$config['speedbar_separator']} " . $tag;

	} elseif ($nam_e) $s_navigation .= " {$config['speedbar_separator']} " . $nam_e;

	if ($titl_e) $s_navigation .= " {$config['speedbar_separator']} " . $titl_e;
	else {

		if ( isset($_GET['cstart']) AND intval($_GET['cstart']) > 1 ){
		
			$page_extra = " {$config['speedbar_separator']} ".$lang['news_site']." ".intval($_GET['cstart']);
		
		} else $page_extra = '';

		$s_navigation .= $page_extra;

	}
	
	$tpl->load_template ( 'speedbar.tpl' );
	$tpl->set ( '{speedbar}', '<span id="dle-speedbar">' . stripslashes ( $s_navigation ) . '</span>' );
	$tpl->compile ( 'speedbar' );
	$tpl->clear ();

}


Меняем на :

if ($config['speedbar'] AND !$view_template ) {
	
	$s_navigation = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"{$config['http_home_url']}\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">" . $config['short_title'] . "</span></a><meta property=\"position\" content=\"1\"></li>";

	if( $config['start_site'] == 3 AND $_SERVER['QUERY_STRING'] == "" AND !$_POST['do']) $titl_e = "";

	if (intval($category_id))
	{
		$cat_breadcrumb = explode("|", get_breadcrumbcategories ( intval($category_id), $config['speedbar_separator'] ));
		$s_navigation .= " {$config['speedbar_separator']} " . $cat_breadcrumb[0];
	}
	elseif ($do == 'tags') {
		
		if ($config['allow_alt_url']) $s_navigation .= " {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"" . $config['http_home_url'] . "tags/\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">" . $lang['tag_cloud'] . "</span></a><meta property=\"position\" content=\"2\"></li> {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">" . $tag . "</span><meta property=\"position\" content=\"3\"></li>";
		else $s_navigation .= " {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"?do=tags\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">" . $lang['tag_cloud'] . "</span></a><meta property=\"position\" content=\"2\"></li> {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">" . $tag . "</span><meta property=\"position\" content=\"3\"></li>";

	} elseif ($nam_e)
	{
		if($dle_module == "showfull")
		{
			$cat_breadcrumb[1] = $cat_breadcrumb[1] + 1;
			$s_navigation .= " {$config['speedbar_separator']} " . "<li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$nam_e}</span><meta property=\"position\" content=\"{$cat_breadcrumb[1]}\"></li>";
		}
		else
		{
			$s_navigation .= " {$config['speedbar_separator']} " . "<li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$nam_e}</span><meta property=\"position\" content=\"2\"></li>";
		}
	}

	if ($titl_e)
	{
		if(isset($cat_breadcrumb[1]) && !is_null($cat_breadcrumb[1]))
			$cat_breadcrumb[1] = $cat_breadcrumb[1] + 1;
		else
			$cat_breadcrumb[1] = 3;
		$s_navigation .= " {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$titl_e}</span><meta property=\"position\" content=\"{$cat_breadcrumb[1]}\"></li>";
	}
	else {

		if ( isset($_GET['cstart']) AND intval($_GET['cstart']) > 1 ){
			$cat_breadcrumb[1]++;
			$page_extra = " {$config['speedbar_separator']} <li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">".$lang['news_site']." ".intval($_GET['cstart']) . "</span><meta property=\"position\" content=\"{$cat_breadcrumb[1]}\"></li>";
		
		} else $page_extra = '';

		$s_navigation .= $page_extra;

	}
	
	$tpl->load_template ( 'speedbar.tpl' );
	$tpl->set ( '{speedbar}', '<ol vocab="http://schema.org/" typeof="BreadcrumbList">' . stripslashes ( $s_navigation ) . '</ol>' );
	$tpl->compile ( 'speedbar' );
	$tpl->clear ();

}


Далее открываем /engine/modules/functions.php, находим :

function get_breadcrumbcategories($id, $separator="&raquo;") {
	
	global $cat_info, $config, $PHP_SELF;
	
	if( ! $id ) return;
	
	$parent_id = $cat_info[$id]['parentid'];
	
	if( $config['allow_alt_url'] ) $list = "<span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"" . $config['http_home_url'] . get_url( $id ) . "/\" itemprop=\"url\"><span itemprop=\"title\">{$cat_info[$id]['name']}</span></a></span>";
	else $list = "<span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$id]['alt_name']}\" itemprop=\"url\"><span itemprop=\"title\">{$cat_info[$id]['name']}</span></a></span>";
	
	while ( $parent_id ) {
		
		if( $config['allow_alt_url'] ) $list = "<span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"" . $config['http_home_url'] . get_url( $parent_id ) . "/\" itemprop=\"url\"><span itemprop=\"title\">{$cat_info[$parent_id]['name']}</span></a></span>" . " {$separator} " . $list;
		else $list = "<span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$parent_id]['alt_name']}\" itemprop=\"url\"><span itemprop=\"title\">{$cat_info[$parent_id]['name']}</span></a></span>" . " {$separator} " . $list;
		
		$parent_id = $cat_info[$parent_id]['parentid'];

		if($parent_id) {		
			if( $cat_info[$parent_id]['parentid'] == $cat_info[$parent_id]['id'] ) break;
		}	
	}
	
	return $list;
}

Меняем на :

function get_breadcrumbcategories($id, $separator="&raquo;") {
	
	global $cat_info, $config, $PHP_SELF, $dle_module;
	
	if( ! $id ) return;
	
	$parent_id = $cat_info[$id]['parentid'];
	$first_id_p = $parent_id;
	$i = 1;
	while($parent_id)
	{
		$i++;
		$parent_id = $cat_info[$parent_id]['parentid'];
		if($parent_id)
			if( $cat_info[$parent_id]['parentid'] == $cat_info[$parent_id]['id'] ) break;
	}
	
	$i += 1;
	$parent_id = $first_id_p;
	if($parent_id == 0)
	{
		$id_i = 2;
		if($dle_module == "cat")
		{
			if( $config['allow_alt_url'] ) $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$cat_info[$id]['name']}</span><meta property=\"position\" content=\"2\"></li>";
			else $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><span itemprop=\"title\">{$cat_info[$id]['name']}</span><meta property=\"position\" content=\"2\"></li>";
		}
		else
		{
			if( $config['allow_alt_url'] ) $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"" . $config['http_home_url'] . get_url( $id ) . "/\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$id]['name']}</span></a><meta property=\"position\" content=\"2\"></li>";
			else $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$id]['alt_name']}\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$id]['name']}</span></a><meta property=\"position\" content=\"2\"></li>";
		}
	}
	else
	{
		$id_i = 3;
		if($dle_module == "cat")
		{
			if( $config['allow_alt_url'] ) $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$cat_info[$id]['name']}</span><meta property=\"position\" content=\"{$i}\"></li>";
			else $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><span itemprop=\"title\">{$cat_info[$id]['name']}</span><meta property=\"position\" content=\"{$i}\"></li>";
		}
		else
		{
			if( $config['allow_alt_url'] ) $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"" . $config['http_home_url'] . get_url( $id ) . "/\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$id]['name']}</span></a><meta property=\"position\" content=\"3\"></li>";
			else $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$id]['alt_name']}\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$id]['name']}</span></a><meta property=\"position\" content=\"3\"></li>";
		}
	}
	while ( $parent_id ) {
		$i--;
		if($dle_module != "cat")
		{
			if( $config['allow_alt_url'] ) $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"" . $config['http_home_url'] . get_url( $parent_id ) . "/\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$parent_id]['name']}</span></a><meta property=\"position\" content=\"{$i}\"></li>" . " {$separator} " . $list;
			else $list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$parent_id]['alt_name']}\" property=\"item\" typeof=\"WebPage\"><span property=\"name\">{$cat_info[$parent_id]['name']}</span></a><meta property=\"position\" content=\"{$i}\"></li>" . " {$separator} " . $list;
		}
		else
		{
			if($id != $cat_info[$parent_id]['id'])
				$list = "<li property=\"itemListElement\" typeof=\"ListItem\"><a property=\"item\" typeof=\"WebPage\" href=\"" . $config['http_home_url'] . get_url( $parent_id ) . "\"><span property=\"name\">{$cat_info[$parent_id]['name']}</span></a><meta property=\"position\" content=\"{$i}\"></li>" . " {$separator} " . $list;
			else
				$list = "<li property=\"itemListElement\" typeof=\"ListItem\"><span property=\"name\">{$cat_info[$parent_id]['name']}</span><meta property=\"position\" content=\"{$i}\"></li>" . " {$separator} " . $list;
		}
		$parent_id = $cat_info[$parent_id]['parentid'];
		if($parent_id) {		
			if( $cat_info[$parent_id]['parentid'] == $cat_info[$parent_id]['id'] ) break;
		}	
	}
	return $list . "|" . $id_i;
}


Далее открываем .css файл который используется где и хлебные крошки и вставляем :

ol[typeof=BreadcrumbList]
{
	display:inline-block;
	list-style:none!important;
}
ol[typeof=BreadcrumbList] > li
{
	display:inline-block;
}


Все.

Скачать хаки dle у нас, как хак обновление хлебных крошек по примеру Google

RDFA-Breadcrumb-dlya-DLE-10.2-11.x.rar [2,38 Kb] (cкачиваний: 63)
  • 100
Добавить комментарий

Оставить комментарий

    • bowtiesmilelaughingblushsmileyrelaxedsmirk
      heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
      winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
      worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
      expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
      disappointedconfoundedfearfulcold_sweatperseverecrysob
      joyastonishedscreamtired_faceangryragetriumph
      sleepyyummasksunglassesdizzy_faceimpsmiling_imp
      neutral_faceno_mouthinnocent