05 февраля 2015

Вот есть ссылка http://web-sputnik.info/raznoe/46-kak-nabrat-na-klaviature-ili

Давайте в ней уберем цифру 46...

 

 

Способ 1

1. Идем в components/com_content и находим там файл router.php
2. Заменяем все его содержимое на:

<?php
/**
* @version $Id: router.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

function ContentBuildRoute(&$query)
{
$segments = array();

$menu = &JSite::getMenu();
if (empty($query['Itemid'])) {
$menuItem = &$menu->getActive();
} else {
$menuItem = &$menu->getItem($query['Itemid']);
}
$mView = (empty($menuItem->query['view']))? null : $menuItem->query['view'];
$mCatid = (empty($menuItem->query['catid']))? null : $menuItem->query['catid'];
$mId = (empty($menuItem->query['id']))? null : $menuItem->query['id'];

if(isset($query['task'])) {
return $segments;
}

if(isset($query['view']))
{
$view = $query['view'];
if(empty($query['Itemid'])) {
$segments[] = $query['view'];
}
unset($query['view']);
};

if (($mView == 'article') and (isset($query['id'])) and ($mId == intval($query['id']))) {
unset($query['view']);
unset($query['catid']);
unset($query['id']);
}

if (isset($view) and ($view == 'section' && !empty($query['Itemid']))) {
if (($mView != 'section') or ($mView == 'section' and $mId != intval($query['id']))) {
$segments[] = 'section';
unset($query['Itemid']);
}
}

if (isset($view) and $view == 'category') {
if ($mId != intval($query['id']) || $mView != $view) {
$temp = explode(':',$query['id']);
if(count($temp) > 1)
{
$query['id'] = $temp[1];
}

$segments[] = $query['id'];
}
unset($query['id']);
}

if (isset($query['catid'])) {

if ((($view == 'article') and ($mView != 'category') and ($mView != 'article') and ($mCatid != intval($query['catid'])))) {
$temp = explode(':',$query['catid']);
if(count($temp) > 1)
{
$query['catid'] = $temp[1];
}

$segments[] = $query['catid'];
}
unset($query['catid']);
};

if(isset($query['id'])) {
if (empty($query['Itemid'])) {
$temp = explode(':',$query['id']);
if(count($temp) > 1)
{
$query['id'] = $temp[1];
}

$segments[] = $query['id'];
} else {
if (isset($menuItem->query['id'])) {
if($query['id'] != $mId) {
$temp = explode(':',$query['id']);
if(count($temp) > 1)
{
$query['id'] = $temp[1];
}

$segments[] = $query['id'];
}
} else {
$temp = explode(':',$query['id']);
if(count($temp) > 1)
{
$query['id'] = $temp[1];
}

$segments[] = $query['id'];
}
}
unset($query['id']);
};

if(isset($query['year'])) {

if(!empty($query['Itemid'])) {
$segments[] = $query['year'];
unset($query['year']);
}
};

if(isset($query['month'])) {

if(!empty($query['Itemid'])) {
$segments[] = $query['month'];
unset($query['month']);
}
};

if(isset($query['layout']))
{
if(!empty($query['Itemid']) && isset($menuItem->query['layout'])) {
if ($query['layout'] == $menuItem->query['layout']) {

unset($query['layout']);
}
} else {
if($query['layout'] == 'default') {
unset($query['layout']);
}
}
};

return $segments;
}

function ContentParseRoute($segments)
{
$vars = array();

$menu =& JSite::getMenu();
$item =& $menu->getActive();
$db =& JFactory::getDBO();
$count = count($segments);


if(!isset($item))
{
$vars['view']  = $segments[0];
$vars['id']    = $segments[$count - 1];
if($vars['view'] == 'article')
{
$query = 'SELECT id FROM #__content WHERE alias = '.$db->Quote($vars['id']);
} elseif($vars['view'] == 'category') {
$query = 'SELECT id FROM #__categories WHERE section > 0 && alias = '.$db->Quote($vars['id']);
}
$db->setQuery($query);
$vars['id'] = $db->loadResult();
return $vars;
}

switch($item->query['view'])
{
case 'section' :
{
if($count == 1) {
$vars['view'] = 'category';

if(isset($item->query['layout']) && $item->query['layout'] == 'blog') {
$vars['layout'] = 'blog';
}
}

if($count == 2) {
$vars['view']  = 'article';
$vars['catid'] = $segments[$count-2];
}

$vars['id']    = $segments[$count-1];

} break;

case 'category'   :
{
$vars['id']   = $segments[$count-1];
$vars['view'] = 'article';

} break;

case 'frontpage'   :
{
$vars['id']   = $segments[$count-1];
$vars['view'] = 'article';

} break;

case 'article' :
{
$vars['id']   = $segments[$count-1];
$vars['view'] = 'article';
} break;

case 'archive' :
{
if($count != 1)
{
$vars['year']  = $count >= 2 ? $segments[$count-2] : null;
$vars['month'] = $segments[$count-1];
$vars['view']  = 'archive';
} else {
$vars['id']   = $segments[$count-1];
$vars['view'] = 'article';
}
}
}

$alias = explode(':', $vars['id']);
if((int) $alias[0] > 0)
{
$vars['id'] = $alias[0];
} else {
if(count($alias) > 1)
{
$vars['id'] = $alias[0].'-'.$alias[1];
}

if($vars['view'] == 'article')
{
$query = 'SELECT id FROM #__content WHERE alias = '.$db->Quote($vars['id']);
} elseif($vars['view'] == 'category') {
$query = 'SELECT id FROM #__categories WHERE section > 0 && alias = '.$db->Quote($vars['id']);
}
$db->setQuery($query);
$vars['id'] = $db->loadResult();
}

return $vars;
}

Недостаток данного способа - при обновлении Joomla этот файл может также обновиться и все ваши старания сойдут на нет.

Способ 2

Этот способ выводит в настройках материала в админке возможность выбрать, удалять или нет ID материала в ссылке:

udalit-id-materiala-v-joomla

Итак: добавляем в файл /administrator/components/com_content/config.xml следующие строки:

<field name="sef_advanced_link" type="radio"
default="1"
label="SEF: Удалить ID материала в ссылке?"
description="Удалить ID материала в ссылке?">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

Если вдруг на некоторых страницах появляется ошибка "404" - следует в файле /components/com_content/router.php строку:

// then we assume it is a category. If they don't we assume it is an article
if ($count === 1) {

заменить на:

// then we assume it is a category. If they don't we assume it is an article 
if ($count === 1 && !$advanced) {

Следует обратить внимание, что строка: if ($count === 1 { может отличаться и быть такой: if ($count == 1 {

 
Добавить комментарий





Практически весь контент размещенный на сайте, вся информация является продуктом студии WSI. Если материалы взяты с других ресурсов, то обязательно указана ссылка на эти ресурсы. Вы можете бесплатно пользоваться информацией с нашего сайта, размещать ее на своих сайтах, но так же обязательна ссылка на наш сайт, Web-Sputnik.Info.


Меню
Копирайт © 2024 'Tochcha' Все права защищены