Page 1 of 1

Remove the category ID from the url

Posted: 28 May 2015, 13:52
by Maximus
Dear developer! First of all thank you for this lovely gallery.

Very hope for your help.

Tell me, please, how can I remove the category ID from the url.

It is very necessary for SEO, because, for example, category:

/gallery/category/1-plants

also available at:

/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla

and so on, because she has a numeric identificator. I need to such pages as:

/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla

would have given a 404 error, and I think it will turn out, if I can remove the category ID: /gallery/category/plants

I think I need to edit the file \www\components\com_phocagallery\router.php, but my knowledge is not enough.

I think the solution would be very useful for many other users.

Many thanks in advance.

P.S. Please, sorry for my bad English.

Re: Remove the category ID from the url

Posted: 31 May 2015, 22:53
by Jan
Hi, I think, this is a Joomla! forum question as the SEF (routes, URLs, ...) are made by Joomla! router methods (JRouter).

Anyway the numbers in urls are good for search outcomes, when the alias is changed, the link is still accessible thank to the number.

Jan

Re: Remove the category ID from the url

Posted: 01 Jun 2015, 22:16
by Maximus
Hello, Jan!

Thanks for your answer!

Yes, in that sense, I agree with You.

But I'd rather get rid of the numbers in the url, and in the event of a change of alias would prescribe redirect in htaccess or by using the appropriate plugin.

I assure You that otherwise, over time, in the Google search will be a large number of duplicates, that eventually will lead to pessimization of the site.

I managed to get rid of the numbers in the url in the categories and articles in Joomla using instructions that I found on the Internet. Just a small edit two lines in the rooter.php file and the problem is solved.

But, unfortunately, it didn't work on gallery categories, as it has its own router...

Re: Remove the category ID from the url

Posted: 03 Jun 2015, 14:54
by Jan
Hi, yes, such you need to customize in the router - somehow detect the ID and parse it somehow with the alias. I didn't do such customization yet, but I think it can work this way:

- instead of IDs you will use only aliases
- when alias is comming - you need to detect it in the database and change to ID - load the items from database by the ID then.

:idea:

Jan

Re: Remove the category ID from the url

Posted: 03 Jun 2015, 19:33
by Maximus
Hi Jan!

Thank You for the reply! Unfortunately, I can't do such adjustments.

If You don't mind, I'll write here changes that remove the ID from categories and news in Joomla 2.5 - Joomla 3.x.

Maybe someone wants to do such and in the Phoca Gallery, and it proves useful in solving the problem.
I would be very grateful if someone will succeed and he will share the solution in this topic.

Editing file: site.com/components/com_content/router.php

1. Line (twice):

Code: Select all

$advanced = $params->get('sef_advanced_link', 0);
Replace with (twice):

Code: Select all

$advanced = $params->get('sef_advanced_link', 1);
2. Find this pice of code:

Code: Select all

if (strpos($segments[0], ':') === false)
{
$vars['view'] = 'article';
$vars['id'] = (int) $segments[0];
return $vars;
}
And comment him:

Code: Select all

/*if (strpos($segments[0], ':') === false)
{
$vars['view'] = 'article';
$vars['id'] = (int) $segments[0];
return $vars;
}*/
That's all.
In any case, thank You very much.

Re: Remove the category ID from the url

Posted: 08 Jun 2015, 11:10
by Jan
Hi, thank you for the guide.

Jan

Re: Remove the category ID from the url

Posted: 12 Feb 2017, 11:31
by bart198x
It's quite old, but I see, nothing changes to the router displaying from few years (since I stop using phoca in 2014 :) ).
I try to read router.php and actualy I was wondering why function

Code: Select all

function PhocaGalleryBuildRoute(&$query)
return $segments , when it is calculated once again in

Code: Select all

function PhocaGalleryParseRoute($segments)
. Doesn't it make doubled $segments or something?
So I just commented

Code: Select all

return $segments;
at the and of

Code: Select all

function PhocaGalleryBuildRoute(&$query)
and I noticed that link in browser changes from
/galeria/jesień-zima-monika/category/2-monika
to
/galeria/jesień-zima-monika
.
I don't know for sure is that correct, but it did the trick. (of course both /galeria and /galeria/jesień-zima-monika are menu items)
Best regards.


it's not so simple, was working until I added more categories :) . So back to the beginning...

Re: Remove the category ID from the url

Posted: 15 Feb 2017, 10:50
by Jan
Hi, there were a lot of changes in router (mostly regarding more menu links, etc.)

There is new router planned in Joomla! so first we need to wait for Joomla! new feature and then such can be implemented (if possible)

But try to seem some SEO guides, displaying the number in URL has mostly more positive implicaciones than negative (great for stablie and long term URLs. In case of different changes, always the same content will be displayed as it is based on number).

Jan

Re: Remove the category ID from the url

Posted: 13 Aug 2017, 14:19
by jacoline
Any plans about hidding /category/catid- in browser url?
Joomla today has the ability (by htaccess) to remove the category/id but it does not affect the gallery. Or perhabs Im just unknown?

Re: Remove the category ID from the url

Posted: 13 Aug 2017, 17:09
by christine
Hi,
Jan wrote: 15 Feb 2017, 10:50There is new router planned in Joomla! so first we need to wait for Joomla! new feature and then such can be implemented (if possible)
History behind: https://developer.joomla.org/news/674-s ... 3-7-0.html
jacoline wrote:Any plans about hidding /category/catid- in browser url?
Plan for Joomla 3.8 > https://www.smartaddons.com/blog/plan-f ... 38-release. Includes also link: discussion new router.

Kind regards, Christine