Re: Why do Tags have the ID in the URL?

983 views
Skip to first unread message

Bakual

unread,
May 6, 2013, 2:39:43 AM5/6/13
to joomla-...@googlegroups.com
Just a guess without a deeper look into it:
  • It's default Joomla behaviour and let's us use standard code to retrieve the correct database row.
  • Looking up an id is faster than looking up a string.
  • Because it's standard, it probably also integrates better with 3rd party SEF extensions.
Also to note: Duplicate tags are NOT ok, as tags should be unique in the table. If you manage to have two tags named "Joomla", they will not match if they have different ids. Duplicate tags would also create a messy list of tags for the selection.

Am Sonntag, 5. Mai 2013 19:17:01 UTC+2 schrieb Josh Lewis:
I am curious why an id is inserted into the url of a tag? I don't see how this is necessary. Unlike articles "duplicates" are okay in the sense that it should and will link to the same tag. But with articles they are obviously unique even if both article titles are "Joomla" and "Joomla".

Josh Lewis

unread,
May 6, 2013, 6:29:14 PM5/6/13
to joomla-...@googlegroups.com
Agreed that looking up an id is better. But what I'm wondering about is why it has to be included in the url?  You said it yourself "Duplicate tags are NOT ok" which means that a duplicate cannot exist. And if that's true, then there is no need for an id in the url because there is no concern about creating a duplicate.

Doesn't wordpress have non-id's for their tags? If so, why not Joomla?

Michael Babker

unread,
May 6, 2013, 6:46:27 PM5/6/13
to joomla-...@googlegroups.com
The current routing system is so heavily tied to the use of IDs that it's nearly impossible to truly remove them at this point.  So, the tag URLs having the ID in the URL isn't a coding decision in the tags implementation but more of a general system item that's in need of review.

--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bakual

unread,
May 7, 2013, 2:43:29 AM5/7/13
to joomla-...@googlegroups.com
As Michael already said, it's how Joomla currently works.
At the end it's a question how you're going to query the database. Currently we use the id to get the row, which of course is the fastest. And it's very easy to strip the id part from the title part in the slug using (int). If we take the number out of the URL, we will have to query the title (or more precisely the alias) instead of the id to get the row.

I think there are 3rd party SEF extensions which do exactly this, but for now, Joomla uses the id and thus the tags do as well.

piotr_cz

unread,
May 7, 2013, 4:58:24 AM5/7/13
to Joomla! CMS Development
Every core Joomla component has a support for advanced routing
(sef_advanced_link), where item in database is being looked up by it's
alias and category, not by Id.

For some reason the option to turn feature on from component
configuration is not provided.

You may enable it manually by editing component parameters in database
(#__extensions > com_tags > params > {"sef_advanced_link":"1",

This works pretty fine for my own component (adds additional db
query), but I'm not sure about tags.
Be warned that this feature probably has been disabled for a reason.


I tracked original commit by Hannes Papenberg:
http://joomlacode.org/gf/project/joomla/scmsvn/?action=ScmCommitDetail&scm_commit_id=71325,
but there's very little info.



On May 7, 12:29 am, Josh Lewis <alpinej...@gmail.com> wrote:
> Agreed that looking up an id is better. But what I'm wondering about is why
> it has to be included in the url?  You said it yourself "Duplicate tags are
> NOT ok" which means that a duplicate cannot exist. And if that's true, then
> there is no need for an id in the url because there is no concern about
> creating a duplicate.
>
> Doesn't wordpress have non-id's for their tags? If so, why not Joomla?
>
>
>
>
>
>
>
> On Sunday, May 5, 2013 11:39:43 PM UTC-7, Bakual wrote:
>
> > Just a guess without a deeper look into it:
>
> >    - It's default Joomla behaviour and let's us use standard code to
> >    retrieve the correct database row.
> >    - Looking up an id is faster than looking up a string.
> >    - Because it's standard, it probably also integrates better with 3rd

brian teeman

unread,
May 7, 2013, 5:43:09 AM5/7/13
to joomla-...@googlegroups.com
That only works in very simple site structures - I spent a lot of time testing that 

piotr_cz

unread,
May 7, 2013, 12:13:22 PM5/7/13
to Joomla! CMS Development
Can you elaborate a little what didn't work fine?

Only thing I can think of is when advanced sef is enabled, every
parsed route executes a db query to get item id. This could become a
problem in case of hundreds of items (tested up to ~200).


BTW: com_tags router ignores 'sef_advanced_link' parameter.


On May 7, 11:43 am, brian teeman <jooml...@googlemail.com> wrote:
> That only works in very simple site structures - I spent a lot of time
> testing that
>
>
>
>
>
>
>
> On Tuesday, 7 May 2013 09:58:24 UTC+1, piotr_cz wrote:
>
> > Every core Joomla component has a support for advanced routing
> > (sef_advanced_link), where item in database is being looked up by it's
> > alias and category, not by Id.
>
> > For some reason the option to turn feature on from component
> > configuration is not provided.
>
> > You may enable it manually by editing component parameters in database
> > (#__extensions > com_tags > params > {"sef_advanced_link":"1",
>
> > This works pretty fine for my own component (adds additional db
> > query), but I'm not sure about tags.
> > Be warned that this feature probably has been disabled for a reason.
>
> > I tracked original commit by Hannes Papenberg:
>
> >http://joomlacode.org/gf/project/joomla/scmsvn/?action=ScmCommitDetai...,

Nick Savov

unread,
May 8, 2013, 6:37:17 PM5/8/13
to joomla-...@googlegroups.com
Check out the following discussion for more info on sef_advanced_link:
https://groups.google.com/forum/?fromgroups=#!topic/joomla-dev-cms/ESxdBp0JkgA

Hope this helps!

Kind regards,
Nick

piotr_cz

unread,
May 9, 2013, 3:36:51 AM5/9/13
to Joomla! CMS Development
Thank you Nick.
I'm not having any issues with sef advanced links (menu item -> List
of Categories; categories and items are nested) yet. Would be cool to
find out why it's failing in some situations.



On May 9, 12:37 am, "Nick Savov" <n...@iowawebcompany.com> wrote:
> Check out the following discussion for more info on sef_advanced_link:https://groups.google.com/forum/?fromgroups=#!topic/joomla-dev-cms/ES...

elin

unread,
May 14, 2013, 8:18:18 PM5/14/13
to joomla-...@googlegroups.com
Just like everything else, if there is a menu link the sef url for a tag will not include an id.  THat is because itemId provides a unique id and we do not need to rely on the id from the component to insure uniqueness.

If I have a tag called Red. And it has an alias of red and then I also have an article called Red with an alias of red ... and neither has a direct or indirect  menu link so there is no itemId and hence no com_menus enforcing that there be unique aliases for menu links at root or with a given parent ... and then someone requests a url of mydomain.com/red .... how does the CMS decide where to go?  We could, of course. say that the url has to be component/tag/red or component/article/red but there is really not much support for that since tag and article are not actually informative about anything and we have to have component thre just in case someone gives a contact the alias of tag or a tag the alias or article..  Just like many of us do not like the demand that we have category names in urls when we may be using categories only for acl purposes not to provide information to site visitors.

I'm hopeful for the future that having unique ids for all items in the common content table will move us toward solving this problem, but there are still a lot of practical questions about how to implement and whether in the end we have to have a look up table of some kind, how to support multilingual, whether we should continue to require core extensions to opt into categories, whether to offer the ability to explicitly write a full url, and so on.  

There's plenty of discussion of url optimization in the WP world also. http://www.labnol.org/internet/clean-wordpress-urls/19301/

One of the interesting things is that Automattic will do url shortening and while that wouldn't be our model I don't think (we'd probably want people to store their own shortened urls rather than a centralized company) maybe that's a dynamic url shortening model  out there. One thing I do like a lot about the WP model is that it lets the user configure how she wants her urls to look.  I'm sure we could do even better than that if we put our minds to it.

Elin. 

Josh Lewis

unread,
May 19, 2013, 7:23:15 PM5/19/13
to joomla-...@googlegroups.com
Why does both a article ID and the article alias have to be unique? I understand that one of them has to be, but forcing both seems like overkill. I think if the ID Vs. Alias issue is resolved we can get a step closer into better SEF urls.

Bakual

unread,
May 20, 2013, 1:52:54 AM5/20/13
to joomla-...@googlegroups.com
I'd say the alias needs to be unique so 3rd party SEF components may use it instead of the id.

Josh Lewis

unread,
May 20, 2013, 2:28:42 AM5/20/13
to joomla-...@googlegroups.com
Then why not remove the id from the article url? The alias can act as the unique identifier considering that there cannot be duplicates of it.


On Sun, May 19, 2013 at 10:52 PM, Bakual <werbe...@bakual.ch> wrote:
I'd say the alias needs to be unique so 3rd party SEF components may use it instead of the id.

--
You received this message because you are subscribed to a topic in the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-cms/4Mr7IG2CpA4/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to joomla-dev-cm...@googlegroups.com.

Ove

unread,
May 20, 2013, 6:34:31 AM5/20/13
to joomla-...@googlegroups.com, Josh Lewis
If I got it right, the alias is not unique within the table. It's only
unique within a category. I would prefer it as unique but what happens
with BC?

Bakual

unread,
May 20, 2013, 1:19:44 PM5/20/13
to joomla-...@googlegroups.com
You can do that with your own SEF plugin :-)

Josh Lewis

unread,
May 20, 2013, 11:11:33 PM5/20/13
to joomla-...@googlegroups.com
You could, but it doesn't have to be that way. WordPress seems to be doing just fine without the ID in content. Why not Joomla?

@Over, your right! It's only unique in the category.  Seems like this idea is creating a potential problem. What if someone displayed multiple categories within the same menu item with a SEF extension? (okay this assumes multiple categories is allowed in a menu item). My point is that this creates a restriction of allowing multiple categories into the same menu item, is that part of the reason it's not built into Joomla?

Bakual

unread,
May 21, 2013, 1:41:11 AM5/21/13
to joomla-...@googlegroups.com
An URL for a single article usually has the category in the URL as well.

The reason it's not an option in Joomla is that nobody coded a working solution yet.

Josh Lewis

unread,
May 21, 2013, 2:37:47 AM5/21/13
to joomla-...@googlegroups.com
Right. In my above post I was talking in theory if multiple categories were able to display in the same menu item in the future. But after much thought I realized why this idea isn't so popular, categories are designed to separate content. And even if one wanted them combined they shouldn't within the same list of content.


On Mon, May 20, 2013 at 10:41 PM, Bakual <werbe...@bakual.ch> wrote:
An URL for a single article usually has the category in the URL as well.

The reason it's not an option in Joomla is that nobody coded a working solution yet.

Alan Sparkes

unread,
May 21, 2013, 3:25:57 AM5/21/13
to joomla-...@googlegroups.com

I think K2 does this with categories...

You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.

elin

unread,
May 21, 2013, 9:04:15 AM5/21/13
to joomla-...@googlegroups.com, in...@joomkit.com
Word Press does not need ids because it stores everything in one table. That is the goal of ucm, to store all the common information in one table so there are unique ideas. But we also want to have multiple content types, the ability to work with extra tables, the ability to manage translations and so on.

Tags enforces unique titles regardless of nesting but within categories and menus we enforce with nesting and that's because it is a really common use case that people want to make a set of categories that all have the same subcategories and menu items. So .. school .. each grade gets a category. Each grade has a blog. Each grade has a calendar. Each grade has a contact form, the site creator really just wants to copy those.and to be able to say to anyone just put calendar at the end of the url for your class (grade1/calendar, grade2/calendar), not grade1/calendargrade1 grade2/calendargrade2  (which is basically the same exact thing as having an id number to make it unique).

About tags
Tags is not hard to implement if you are using Joomla architecture. As always if you are doing something else you will need to write custom solutions to do things like write to the mapping table and store your data.  

Currently we are in a transitional stage and because we care deeply about backward compatibility we are storing two copies of some data (just as we do with smart search)  when people use tags. Of course we won't do that for the long term with the core, and then it will be up to extension developers to decide what they want to do in terms of that.   Nested tags is a feature that already has shown itself to be extremely powerful and useful. I don't think it's any slower than categories, but you may be on to something if it is the case that people will create a lot more tags than they do categories. I have a feeling you haven't tried to create a few thousand categories. We've paid less attention to the  com_tags backend than to the tags api and front end queries so that is definitely an issue to solve, and looking at how to manage nesting in both categories and tags is something that we will do between now and 3.2 because it is extremely important to manage that correctly and in a performant way as part of ucm.  

Anyway, that doesn't really have anything to do with the question of why we currently need numbers in urls when we don't have menu items.

Elin

Bakual

unread,
May 21, 2013, 2:50:07 PM5/21/13
to joomla-...@googlegroups.com
It's not the same as categories. Tags span across multiple extensions (which is awesome), while categories are extension specific. Also as you said an item can have multiple tags, but only one category.
 
It's not that hard to implement in a 3rd party extension once you figured it out (and read the docpage). But it's true that we have duplicated data now. That's what Elin meant with "transitional state". The idea is to remove the duplicate data once UCM is in place.

Am Dienstag, 21. Mai 2013 09:20:09 UTC+2 schrieb Hassan Amouhzi:
Hello,

I studied the system Joomla tags, and I have some comments:

1 - It is like a second category management (same functions nested, left, rgt, parent ...)
The difference is that we can assign more than one label to an article.

2 - The system is very complex to implement by others, I also think that there are duplicates in the database, for example # _ucm_core_content have the same fields as # _content

We lose performance for something that category management is already doing, and the last system is enough.

I tried to insert a few thousand tags and my machine crashed: For each tag (nested), the system must make changes in all the records of the table # _tags.


I think for the tags, it is preferable to use a single ordering field instead of lft, rgt.

Thong Tran

unread,
Nov 22, 2013, 4:11:32 AM11/22/13
to joomla-...@googlegroups.com
I've just made a blog with a solution without core-hacking, take a look: http://foobla.com/blog/5141-remove-joomla-3-tags-id-in-the-url

Thong

Grigor Mihov

unread,
Nov 22, 2013, 6:57:59 AM11/22/13
to joomla-...@googlegroups.com
This solution is pretty dirty.
The better one would be to make a .htaccess redirect
1. Create a new menu item to all tags (could be in some hidden menu). Put as alias "tag" for example.
2. Add this line in your .htaccess bellow RewriteEngine On:

RewriteRule ^component/tags/tag/(.*)$ /tag/$1 [R=301,NC,L]

The ID will still be there, but the solution is much clear.
Reply all
Reply to author
Forward
0 new messages