1.) Create a menu type "Menu Item Alias", point it to another menu item, preferably to one of its direct submenus, for instance:
Point "agency" to "team", wich is a standard single-article menu item
2.) The Menu path in this case would be for instance:
www.yourdomain.com/en/agency/team
3.) Now open this:
www.yourdomain.com/en/agency
Redirect to www.yourdomain.com/en/agency/team with a 301 code
Shows statistics about number of articles in different categories
Joomla 3.8.x
Labels |
Added:
?
|
This is a community developed software. You don't have to get permission. Contribute if/when you can so go for it.
I am not able to find articles when logged into admin panel of joomla website. Can anyone find the reasons and give solution to this problem?
@Rmkrishan
Please use the forums. This concerns joomla coding. Thanks!
@pixxelfactory
I cannot reproduce your issue here.
Both /en/agency
and /en/agency/team
display the article concerned.
You may have another menu/extension creating this problem
Note: this is evidently on a multilingual site.
What is the solution to this problem?
@Rmkrishan Your issue appears not to be a bug in the core software. Please post your question to the Joomla forums.
Hi folks. At least some part seems a bug in the Core. A non cached 301 redirect should exist. else you have two different URLs for one page which shouldn't exist, also note the breadcrumb is different, which probably means the menu assigment (ex: modules) will not be respected Unless you assign to both menu items.
Example of a non cached 301 redirect https://github.com/joomla/joomla-cms/blob/staging/plugins/system/languagefilter/languagefilter.php#L454
As for the statistics, in our case it probably was some joomla-update error or some thing like it, because we tried to reinstall the core files via joomla-update, it now shows the target article.
But it does not perform a 301 redirect to the target url, wich is not the best solution (duplicate urls, different breadcrumbs and module assignments as mentioned).
I wrote a small plugin that performs the redirect if the current menu is a menu alias, code, also made sure that the redirect is not cached as mentioned by @andrepereiradasilva and used the code from the language-filter plugin. What do you think about this approach as temporary solution?
<?php
/**
* @package System Plugin - Small redirect plugin for menu aliases
* @version 0.0.1 Alpha
* @author Alex Franzelin
* @copyright (C) 2018 - Alex Franzelin
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
// no direct access
defined('_JEXEC') or die();
/**
* Plugin redirects user to target menu if the current menu item is an alias
**/
class plgSystemAlias extends JPlugin
{
/**
* @param $subject
* @param $config
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Perform menu-check after routing
**/
public function onAfterRoute()
{
$app = JFactory::getApplication();
// Only on the frontend
if($app->isSite())
{
$active = $app->getMenu()->getActive();
$params = $active->params;
// If current menu is alias..
if($active->type == 'alias')
{
// ..do not cache this redirect like mentioned in the github thread..
$app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
$app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
$app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
$app->setHeader('Pragma', 'no-cache');
$app->sendHeaders();
// ..get the target menu-id and redirect user
$target = $params->get('aliasoptions');
$route = JRoute::_('index.php?Itemid='.$target);
$app->redirect($route);
}
}
}
}
IMHO a change like that should be done at core Router level, not at plugin level - since the menu system is a part of the core.
Also since the Admin app also as the alias menu item in it's menu system it should be done for the SiteRouter and the AdministratorRouter.
Not sure, because i don't fully understand the routing system, but probably at the end of the parse route method . Example, adding in the "SiteRouter" https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Router/SiteRouter.php#L139
// If it's a alias menu item type do a non cached 301 redirect to the real menu item.
$active = $this->menu->getActive();
if ($active !== null && $active->type === 'alias')
{
$this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
$this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
$this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
$this->app->setHeader('Pragma', 'no-cache');
$this->app->sendHeaders();
$this->app->redirect(\Joomla\CMS\Router\Route::_('index.php?Itemid=' . $active->params->get('aliasoptions', $this->menu->getDefault()), false), 301);
}
Basic tests seems to work. Of course would need to be fully reviewed and checked for someone who understands the core router system better than i do. ex: @csthomas :)
Yeah, i just wrote the plugin as temporary solution (since i need to fix this bug today, because the client is not amused ;-) ).
Status | New | ⇒ | Discussion |
Category | ⇒ | com_content |
@pixxelfactory - how do i use or insert your Plugin?
I tried but .... no clue :-D
@lenusch
Hi, simple:
create a directory inside plugins/system named "alias"
In there place three files:
<?xml version="1.0" encoding="utf-8"?> <extension version="3.0" type="plugin" group="system" method="upgrade"> <name>plg_system_alias</name> <author>pixxelfactory</author> <creationDate>January 2018</creationDate> <copyright>(C) 2018 pixxelfactory</copyright> <license>GNU General Public License v3; see LICENSE.txt</license> <authorEmail></authorEmail> <authorUrl>www.pixxelfactory.net</authorUrl> <version>0.0.1</version> <description>PLG_SYSTEM_ALIAS_XML_DESC</description> <files> <file plugin="alias">alias.php</file> <filename>index.html</filename> </files> <languages> <language tag="en-GB">language/en-GB/en-GB.plg_system_alias.sys.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> </fieldset> </fields> </config> </extension>
After that, inside the Joomla-Administration go to:
Extensions/Manage/Discover and click the Discover-Button, check the alias plugin, install and afterwards activate it.
That's it
Best regards
pixxelfactory
@pixxelfactory thank you! before I used my plugin installer Script and generated a zip. it was installed correctly but i can't see where the File was placed :-D
worked good - thanks!
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-09-28 21:11:03 |
Closed_By | ⇒ | Quy |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19340
Please test PR #22432
Hi I am new to opensource and want to contribute. Can I work on this issue?