Itemid refactoring in 1.5

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Itemid refactoring in 1.5

Post by Jinx » Tue Feb 13, 2007 5:16 am

Hi all,

In the last 3 weeks I have been working hard on refactoring the whole itemid handling in 1.5. Currently 75% of the work is done and the changes have been implemented in both the weblinks and the newsfeeds components. This thread is intended to inform you about the changes in itemid behavior and to answer questions.

Before diving into the changes and howto's let me show you what this baby can do. The new system is capable of producing links like :

1. http://localhost/joomla15/index.php/web ... oomla      (link to weblink)
2. http://localhost/joomla15/index.php/the ... w/faq                    (submenu item)
3. http://localhost/joomla15/index.php/new ... -news  (link to newsfeed)

These links are : unique, humanly readable, hierarchical and their creation doesn't require any overheat. Yep that's right, zip zero ovehead. Juts like we want it !

First of all, the changes are fully backwards compatible and shouldn't have any effect on older components. So far this is untested, but 1.5 is running components with the old style of url handling and the new style without any problems. In case you have a component that runs in legacy mode and cannot handle the new url routing system let me know so we can make sure everything is 100% BC.

Before diving into the specifics of what has been changed I would like to explain some of the concept changes. In Joomla! 1.0 we had something called SEF (search engine friendly URL's). A nice name but something like a SEF URL doesn't really exist. In accessibility terms we can talk about humanly readible URL's, or if we look at URL's on a system architecture level we can talk about routes. This is also what we will be calling them from now on : 'routes'.

If you pop open the hood of the latest SVN you will notice that we added and implemented a JRouter object. JRouter is a class that is responsible for building and parsing routes. You will also notice that we split up the JApplication::excecute function into a route and dispatch function.

Routing : Routing is the process of examining the request environment to determine which which component should receive the request. This component optional parameters are then set in the request object to be processed when the application is being dispatched.

Dispatching :  Dispatching is the process of pulling the option from the request object and mapping them to a component. If the component do not exist, it handles determining a default component to dispatch.

The JApplication::route function is responsible to create the router object and parse the request URI. The router examines the request and tries to match the itemid based on the application route (part of the total route defined by the menu). The component route (remaining part) is passed on to the specific component router handling functions.

A component can handle it's own routing process by adding a router.php file and in this file defining a MycomponentParseRoute and MycomponentBuildRoute function.

1. Parse function

The parse function passes in an array that contains the different parts of the route. It's up to the component to decide how to interpret the information in this array and push or translate relevant into JRequest.

2. Build function

The build function passes in an array that contains the query part of the URL. It's up to the component to decide how to translate this information into a route.

If you would look at it from a decoder/encoder perspective, the build function is the encoder and the parse function the decoder. The component can decide for himself how to handlin the decoding/encoding process and doesn't need to rely on a plugin or external algoritm to do this.

In case the component decides not to handle the routing process JRouter will simply use the information in the query array to create a full query string. The component can also decide not to handle part of the query info and pass it back to JRouter in which case JRouter will append it to the and route as a URL query string. (a good example of this is com_search).

The changes also make creating routes alot easier. You don't need to specify the option and Itemid anymore in the sefRelToAbs function. This the following piece of code is valid :

Code: Select all

$link = sefRelToAbs( 'index.php?view=x&id=x);
As you can notice we are not specifying the option nor the itemid. JRouter will add both based on the information that is already present in the request. You also don't need to use & 's. JRouter converts the & to &amps; for you.

These changes makes creating routes (URL's) in 1.5 alot easier and more straightforward. A nice side-effect is the fact that components don't need to know about $option and $Itemid anymore. It's only the application (JSite) who needs to know about both. This opens a whole new world of possibilities as a component is not tied anymore to it's own name.

I think it's best you have a look at com_weblinks and com_newsfeeds to see the changes in action. If you have any questions, which i'm sure you do, don't hesistate to ask them.

Enjoy !

Johan

Note A : The new architecture has also been implemented in such a way that it can easily be decorated/extended. No more hacking of the core, solutions like OpenSEF can now truly focus on becoming URL management extensions. Which is what they are in the first place.

Note B : The changes are not fully complete yet. I still need to

- Implemented the changes in all other frontend components
- Sync the pathway with the router to improve the pathway handling
- Fix issues related to pagination
- Fix issues related to redirects
- ....
Last edited by Jinx on Tue Feb 13, 2007 5:18 am, edited 1 time in total.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 18871
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Itemid refactoring in 1.5

Post by infograf768 » Tue Feb 13, 2007 7:04 am

Image
Jean-Marie Simonet / infograf · http://www.info-graf.fr
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
brad
Joomla! Master
Joomla! Master
Posts: 13419
Joined: Fri Aug 12, 2005 12:38 am
Location: Sydney - Australia
Contact:

Re: Itemid refactoring in 1.5

Post by brad » Tue Feb 13, 2007 7:23 am

Wonderful news! :D
Brad Baker
https://xyzulu.hosting
https://www.joomlatutorials.com <-- Joomla Help & Tutorials

User avatar
vancanneyt
Joomla! Ace
Joomla! Ace
Posts: 1098
Joined: Fri Aug 19, 2005 9:30 pm
Location: Buiten de wereld
Contact:

Re: Itemid refactoring in 1.5

Post by vancanneyt » Tue Feb 13, 2007 7:25 am

fantastic work johan! i love the new way, tested it already and also tested with a few custom components and it all works verry well. This improvement is verry good.
Member of the Dutch (nl-NL) translation team - http://joomla.taalbestand.nl - http://joomlacode.org/gf/project/nederlands/

karol.cejka
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 177
Joined: Thu Nov 10, 2005 10:22 am
Location: Prague, Czech Republic
Contact:

Re: Itemid refactoring in 1.5

Post by karol.cejka » Tue Feb 13, 2007 8:11 am

Good news for users and developers.
Have you some UNIT tests for controlling refactored functionality?
Karol Čejka · CET (UTC+1)
* Slovak (sk-SK) Joomla! Translation
* Slovak (sk-SK) Translation Services

User avatar
tsimpo
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Thu Sep 15, 2005 5:09 am
Location: Greece
Contact:

Re: Itemid refactoring in 1.5

Post by tsimpo » Tue Feb 13, 2007 9:38 am

What can I say?

I LOVE you... :-*
Joomla sites. http://www.webcase.gr Υπηρεσίες Internet, websites, Joomla! dedicated services.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11765
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Itemid refactoring in 1.5

Post by brian » Tue Feb 13, 2007 9:57 am

Thank you,good work.Glad to see you using the term Human Readable
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
newart
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3177
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: Itemid refactoring in 1.5

Post by newart » Tue Feb 13, 2007 10:06 am

Jinx wrote: 1. http://localhost/joomla15/index.php/web ... oomla&nbsp;      (link to weblink)
2. http://localhost/joomla15/index.php/the ... w/faq&nbsp;                    (submenu item)
3. http://localhost/joomla15/index.php/new ... -news&nbsp; (link to newsfeed)

These links are : unique, humanly readable, hierarchical and their creation doesn't require any overheat. Yep that's right, zip zero ovehead. Juts like we want it !
What can I say... no words for describing that  :o the state of the art... wonderful!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
former Q&T WorkGroup Joomla member - Italian Translation Team Member

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11765
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Itemid refactoring in 1.5

Post by brian » Tue Feb 13, 2007 10:10 am

Can you explain what the numbers mean. I've made a guess but need to be sure.
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
nicholai
Joomla! Explorer
Joomla! Explorer
Posts: 293
Joined: Sun Jun 11, 2006 10:29 am
Location: Netherlands
Contact:

Re: Itemid refactoring in 1.5

Post by nicholai » Tue Feb 13, 2007 10:15 am

Great Johan, but i did not totally understand what I should put in router.php. Would you please add some more comments?

Thx
Founder and Lead developer of JAM (http://joomladev.org)
JAM is the first J!1.5 only component using AJAX!

User avatar
Robin
Joomla! Master
Joomla! Master
Posts: 15753
Joined: Thu Aug 18, 2005 10:41 am

Re: Itemid refactoring in 1.5

Post by Robin » Tue Feb 13, 2007 10:19 am

Interesting and big improvement to the Itemid. One question though Johan, will this change break migrations from 1.0 to 1.5?

Thanks Robin


Edit; just read it again, should be compatible... will require extra attention for Q&T!
Last edited by Robin on Tue Feb 13, 2007 10:26 am, edited 1 time in total.

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: Itemid refactoring in 1.5

Post by Jinx » Tue Feb 13, 2007 12:01 pm

Hi all,

Thanks for the feedback, this post is primarily intended to solve questions from developers. I will do a more community oriented post on the blog once I feel comfortable we have dealt with the questions developers are having.

@Brian : The numbers are the actual category or content item id's. Having the numbers in the URL has two advantages, first of all I don't need an extra querie to find them and second it allows for unqiue URL's. We will leave it up to URL managament solutions like OpenSEF to extend the system and allow URL's that don't have these numbers. T

@Nicolai : could you try to be more descriptive about what you don't understand ? Makes it a bit easier to reply.

@karol.cejka : No Unittests I'm afraid, but I'm quite confident things will not break.

@Robin : System is BC. There are a few changes as how aliasses for categories and sections are stored but those can be handled by the migration script.

Johan
Last edited by Jinx on Tue Feb 13, 2007 12:02 pm, edited 1 time in total.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11765
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Itemid refactoring in 1.5

Post by brian » Tue Feb 13, 2007 1:53 pm

so does that mean that there is no longer any paramater (think menuid) in the url that associates the content with the menu?
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11765
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Itemid refactoring in 1.5

Post by brian » Tue Feb 13, 2007 2:05 pm

Johan can you blog this at dev.joomla.org I think it will get wider readership there
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
vancanneyt
Joomla! Ace
Joomla! Ace
Posts: 1098
Joined: Fri Aug 19, 2005 9:30 pm
Location: Buiten de wereld
Contact:

Re: Itemid refactoring in 1.5

Post by vancanneyt » Tue Feb 13, 2007 2:05 pm

Johan, Just a small question about developing content URL's and category section links in a component, is it something like this?
index.php?view=article&id=". $rows->id ."&Itemid=43
but here it just adds the id number and not the new way of number and title, so how do we create the correct links like the examples you gave?
When i look to your example it should look like this:
index.php?view=article&id=". $rows->id .":".$rows->title_alias."&Itemid=43
Is this correct or can we do it in an other way?
Member of the Dutch (nl-NL) translation team - http://joomla.taalbestand.nl - http://joomlacode.org/gf/project/nederlands/

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Itemid refactoring in 1.5

Post by AmyStephen » Tue Feb 13, 2007 2:57 pm

Johan -

This goes WELL BEYOND expectations. You rock!  8)

Thank you sincerely,
Amy :)

User avatar
markuz
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 225
Joined: Tue Nov 08, 2005 6:43 pm
Location: the Netherlands
Contact:

Re: Itemid refactoring in 1.5

Post by markuz » Tue Feb 13, 2007 3:23 pm

Johan,

I'll say it in Dutch: Petje af! (translated freely: I take of my hat for this, well done!)

Just read this thread about this. Well done, this is really a great development in Joomla! I still have to figure out some things how to use this optimally in my own code. There are still some little issues to be solved that are on your list.

I already posted about an issue you already put on your list, just a reminder: http://forum.joomla.org/index.php/topic,139725.0.html

Again: great work!

Mark

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: Itemid refactoring in 1.5

Post by Jinx » Tue Feb 13, 2007 4:13 pm

brian wrote: so does that mean that there is no longer any paramater (think menuid) in the url that associates the content with the menu?
It works a bit different, internaly Itemid's still exist and they always will. We will always need to have an identifier for the menu item. Externaly the Itemid=x is not added anymore to the URL's Joomla creates. The system is now smart enough to deal with these himself. I will also blog about it but I want to give developers the time to provide feedback first. That's how we do things around here, built the code, listen to our third party guys and then inform the joomlasphere. I'm sure Amy will already write something about this forum thread on her blog though ;)
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Itemid refactoring in 1.5

Post by AmyStephen » Tue Feb 13, 2007 4:40 pm

hehehe! Well, I have obviously earned a solid reputation for my BIG, ENORMOUS mouth! I do try to use my powers for good, though, if I can - and I look at it this way, Johan, if all you got is a big mouth, then, dammit - put your big mouth to good use for the community!
I bring my gifts.  8)

But - to be honest, I did read you say "I will do a more community oriented post on the blog once I feel comfortable we have dealt with the questions developers are having." And, thus, concluded that perhaps you wanted a bit of time to work with your developer community before going more broadly with this.

OK. I must admit. That was a bit like cold water thrown on my blogging face. But, I decided that, for the cause, (ItemIDs and URLs obviously being the big double-whammy in the Joomla! "cause" department), I concluded it might be best if I demonstrated seldom seen restraint and waited to see how the conversation went. Patiently. Until you say it's okay. Waiting for your word. I am w*a*i*t*i*n*g, Johan. Tick-tock.

I guess it's more important that this be done, then that I say something. In this case, only, of course. And, I still can be happy on the inside and that won't hurt anyone, at all!
HUGE news. Will blog after your community post. (Or when you say so.) Thanks for letting me get a blog out of my system here in your thread. That helped.  :P
Amy :)
PS - Thanks again. This is going to be very good for Joomla!, as you well know.

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: Itemid refactoring in 1.5

Post by Jinx » Tue Feb 13, 2007 5:01 pm

Sander,
vancanneyt wrote: Johan, Just a small question about developing content URL's and category section links in a component, is it something like this?
index.php?view=article&id=". $rows->id ."&Itemid=43
but here it just adds the id number and not the new way of number and title, so how do we create the correct links like the examples you gave?
When i look to your example it should look like this:
index.php?view=article&id=". $rows->id .":".$rows->title_alias."&Itemid=43
Is this correct or can we do it in an other way?
You, as a component developer are responsible to decide how your links will look like. com_weblinks and com_newsfeeds use, a link format that is hierarchical and unique, it does that by adding the so called slug to the link. You are correct in saying that the id is generated like

Code: Select all

id=$row->id.':'.$row->title_alias.
This is one way to do it and the way the core will be doing it. Does that mean this is the only way ? Definitly not. Let's have a look at one of the newsfeed links to get a better idea of how this works. In com_newsfeeds for the actual newsfeed item link we do the following (com_newsfeeds/views/category/view.html.php line 82)

Code: Select all

$item->link =  sefRelToAbs('index.php?view=newsfeed&catid='.$category->slug.'&id='. $item->slug );
This code is reponsible for creating the route (URL) for a newsfeed item. As you can see I'm passing in two things :

- catid : the newsfeed category identifier slug
- id    : the newsfeed item identifier slug

The slug is this case is created by the categories model on line 113 for the id (item) slug and on line 195 for the catid (category) slug. The slug is a combination of the id and the alias.

The newsfeeds components is adding both the category and item slug to the URL to be able to create hierarchical URL's. Not all components need to or will be doing it like this but it's best to create hierarchical URL's for content driven components. In the core this means com_newsfeeds, com_weblinks, com_contact, com_content, com_banners. Other component can use a different formatting.

Building the URL

Now, when sefRelToAbs is called it will fire up JRouter and ask him to build the route. The buidling process is divided into two steps :

1. Create the application (menu) route, based on the Itemid
2. Create the component route, based on the extra information you passed into sefRelToAbs

This will result in a URL like /index.php/applicationroute/componentroute?query....

Step 1 you don't need to worry about, JRouter is a big boy and he handles that one for you. Step 2 is the one you are in charge of by adding the router.php file to your component. Let's see what com_newsfeed does here :

Code: Select all

function NewsfeedsBuildRoute(&$query)
{
	$parts = array();
	
	if(isset($query['catid'])) 
	{
		$parts[] = $query['catid'];
		unset($query['catid']);
	};

	if(isset($query['id'])) 
	{
		$parts[] = $query['id'];
		unset($query['id']);
	};
	
	unset($query['view']);

	return $parts;
}
As you can see, it's pretty simple. The NewsfeedsBuildRoute function receives a $query array examines it and adds the relevant parts in the right order to the $parts array and returns this one.

In case of the example link it means that JRouter will add the $category->slug and the $item->slug to the route, which gives the following result :

index.php/applicationroute/$category->slug/$item->slug

You will notice that the function also unsets the information from the query array. You need to do this, otherwise JRouter will add this info to the URL in the form of a query string.

Parsing the URL

The parsing of the route is also a two step process, in the first step JRouter tries to find the correct Itemid based on the application route. In the second part the component router is called to handle the remaining parts of the route that are left unhandled by JRouter.

As I already explained parsing the URL is the opposite process of building it. The trick is to understand the structure of the URL filter the needed information and push this into JRequest.

In com_newsfeeds we do the following :

Code: Select all

function NewsfeedsParseRoute($parts)
{
	$menu =& JMenu::getInstance();
	$item =& $menu->getActive();

	// Count route parts
	$nArray = count($parts);
	
	//Handle View and Identifier
	switch($item->query['view'])
	{
		case 'categories' :
		{
			if($nArray == 1) {
				$view = 'category';
			}

			if($nArray == 2) {
				$view = 'newsfeed';
			}

			$id = $parts[$nArray-1];

		} break;

		case 'category'   :
		{
			$id   = $parts[$nArray-1];
			$view = 'newsfeed';

		} break;
	}

	JRequest::setVar('view', $view, 'get');
	JRequest::setVar('id', (int)$id, 'get');
}
The magic here is that we need to know in what level of the hierarchy we are by examining the root element. We do this by looking at the parent view name of the active menu item and we also look at the size of the parts array :

Here we request the menu item view :

Code: Select all

$item-query['view']
Here we calculate the number of items in the parts array :

Code: Select all

$nArray = count($parts);
These two pieces of info allow us to correct filter the info passed through in the parts array. As you can see in the code we are handling 3 different cases :

1. The menu item is a link to the newsfeed catagories view and the parts have two items, in this case we know we have a link to a newsfeed item

2. The menu item is a link to the newsfeed categories view and the parts have one item, in this case we know we have a link to a newsfeed category

3. The mnu item is a link to a newsfeed category, in this case we know the that we extra information in the URL is the identifier of the newsfeed item.

At the end of the function we are setting both the right view and the right identifier, after which JApplication dispatch can take over.

And voila all done ! ;)
Last edited by Jinx on Tue Feb 13, 2007 5:11 pm, edited 1 time in total.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
vancanneyt
Joomla! Ace
Joomla! Ace
Posts: 1098
Joined: Fri Aug 19, 2005 9:30 pm
Location: Buiten de wereld
Contact:

Re: Itemid refactoring in 1.5

Post by vancanneyt » Tue Feb 13, 2007 8:44 pm

thanks for your clear awnser Johan
I guess for easy and fast making a content link in a component is the short id=$row->id.'://'.$row->title_alias.
I saw also in latest SVN that after the id ther is more then a :, zo it's ID://TITLE_ALIAS

some things i noticed:
administrator link has got itemid: http://www.localhost/administrator/?Itemid=1
Frontpage links have a double Itemid: http://localhost/index.php?option=com_c ... 1?Itemid=1

I like the new way very much, big step for Joomla ;)
Member of the Dutch (nl-NL) translation team - http://joomla.taalbestand.nl - http://joomlacode.org/gf/project/nederlands/

Brenda
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Thu Mar 02, 2006 4:12 am

Re: Itemid refactoring in 1.5

Post by Brenda » Tue Feb 13, 2007 10:33 pm

This sounds great - but wondering...

I don't understand any of how this works but I once used a script that generated urls with colons.
The site worked fine but I had problems with spiders & browers & interaction with other scripts.

This was only a couple of years ago and maybe things are handled differently but some of the problems I faced were:

xml url parsing
link checking failed - bad url
pages couldn't be cached
colon stripped by some scripts
some browsers chopped at the colon -
bbc code chopped at the colon - mysite/folder/1 instead of mysite/folder/1:page.html
invalid protocol on relative links (offline browsing)
javascript problems


404/403 logs were ridculous - the more incoming links the worse it got.

Most of the problems I couldn't control - ever tried asking a forum to fix their bbc code just for you or asking a webmaster to alter a recip link checking script....

Anyway was just curious whether any of the above still apply.

Maybe the server I was on was configured wrong, maybe it was the script I have no idea, but I eventually just threw it out & started over.

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: Itemid refactoring in 1.5

Post by Jinx » Wed Feb 14, 2007 12:07 am

Colons are valid ANSI characters and thus can be used in URL's. I'm guessing from what you are telling me that you had another problem at play. The technique we are using to create our URL's is being used by other web applications too, so far I haven't read about anything negative.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
kenmcd
Joomla! Champion
Joomla! Champion
Posts: 5672
Joined: Thu Aug 18, 2005 2:09 am
Location: California
Contact:

Re: Itemid refactoring in 1.5

Post by kenmcd » Wed Feb 14, 2007 2:18 am

The colon is actually a Reserved Character (per RFC 3986, January 2005).
It is further classified as a gen-delim which should be % percent escaped unless used in a URI Scheme.
Obviously the colon is a part of the HTTP scheme (such as http://www.joomla.org:80/)
Also used in username:password.
Also used in some XML feeds and other standardized formats which carry URLs as content.

Reserved Characters
gen-delims  =  : / ? # [ ] @
sub-delims  =  ! $ & ' ( ) * + , ; =

The reserved character sub-delims would be less likely to cause an issue.
But they are odd to see in a human readable URL as they mean other things in text.

Highly recommend you do not use the colon.
An unreserved character such as the dash (-) would be far safer to use.
Last edited by kenmcd on Wed Feb 14, 2007 2:23 am, edited 1 time in total.
██ LibreTraining

Brenda
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Thu Mar 02, 2006 4:12 am

Re: Itemid refactoring in 1.5

Post by Brenda » Wed Feb 14, 2007 4:29 am

Think I worded some of that wrong.

The majority of errors were not on my site - they were caused by other sites & the way their scripts handled the colon: the biggest problem being the url getting chopped short for incoming links.

I just got worried when I saw the colon & thought I'd ask.

doko
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Aug 25, 2005 11:22 pm

Re: Itemid refactoring in 1.5

Post by doko » Wed Feb 14, 2007 6:40 am

Fantastic work!

Tested it against several components I have written - brilliant. 

While testing the components and for what it is worth (given it is 75% written) - I thought what would happen if point two menus to one article.  To test it I created two sub-menus under different parent menus.  Irrespective of which sub-menu is selected, only one sub-menu works.

ie.
Menus: Apple and Lemon

Sub-menus for Apple:
Apple -> Granny Smith;
Apple -> Pink Lady;
Apple -> Red Delicious;
Apple -> Care.

Sub-menus for Lemon:
Lemon -> Meyer;
Lemon -> Dorshapo;
Lemon -> Care.

If:
- Care points to the same article for both Apple and Lemon; and
- The menu options include Activate Parent & Full Active Highlighting.

Subsequently, the correct article is shown, but irrespective of whether Apple->Care or Lemon->Care is selected from the menu list, the menu list will show Lemon->Care as active.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11765
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Itemid refactoring in 1.5

Post by brian » Wed Feb 14, 2007 8:02 am

Jinx wrote: Colons are valid ANSI characters and thus can be used in URL's. I'm guessing from what you are telling me that you had another problem at play. The technique we are using to create our URL's is being used by other web applications too, so far I haven't read about anything negative.
This RFC may be of interest http://tools.ietf.org/html/rfc3986
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: Itemid refactoring in 1.5

Post by pollen8 » Wed Feb 14, 2007 10:13 am

Cool work!

I've not looked under the hood, but I was wondering why its not possible to create a route with an array key'd on a text value: e.g. when building the route, if i try to use:

Code: Select all

if(isset($ARRAY['layout'])) {
		$parts['layout'] = $ARRAY['layout'];
		unset($ARRAY['layout']);
	};
rather than

Code: Select all

if(isset($ARRAY['layout'])) {
		$parts[] = $ARRAY['layout'];
		unset($ARRAY['layout']);
	};
when I come to parse the route I still get my $parts array shown as :

Code: Select all

Array
(
    [0] => profile
)
rather than

Code: Select all

Array
(
    ['layout'] => profile
)
being able to access the layout via $parts['layout'] would be more readable than $parts[0] perhaps?
aka

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: Itemid refactoring in 1.5

Post by pollen8 » Wed Feb 14, 2007 10:54 am

also is there any way to remove the "index.php" from the url?

e.g.

http://localhost/joomla15/index.php/component/2

becomes

http://localhost/joomla15/component/2
aka

Alejo
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 219
Joined: Fri Aug 19, 2005 12:28 pm
Contact:

Re: Itemid refactoring in 1.5

Post by Alejo » Wed Feb 14, 2007 12:27 pm

Jinx wrote: As you can notice we are not specifying the option nor the itemid. JRouter will add both based on the information that is already present in the request. You also don't need to use & 's. JRouter converts the & to &amps; for you.
Hi.

What would happen with components that allow different functionality based on different settings of a menu parameter? Right now those menus look like this:

index.php?option=com_component&Itemid=x
index.php?option=com_component&Itemid=y
index.php?option=com_component&Itemid=z

But they all do different things since the task is processed internally based on the menu parameter. Will it be possible to display the task for those menus using the new class?

Thanks!

Alejo
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress


Locked

Return to “Joomla! 1.5 Coding”