sef urls for custom component, which variant is better?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

sef urls for custom component, which variant is better?

Post by devlabs » Wed Mar 03, 2010 10:02 am

Am developing custom component for joomla.
I need sef urls for my custom component.
Joomla has a lack of sef urls.

There are two main components on the market:
- Artio sef
- Sh404sef

I installed artio
The problem is that it stores all sef urls in the db, and it’s alike +100queries for the main page of the component. I have a lot of duplicates like custom-1 custom-2 custom-3
Is that the principle of it’s work, to store everything in db and then just to replace? Or it’s because I haven’t written custom extention for my component?

I installed sh404sef and looks like it isn’t using db for storing sef urls. But it looks like complicated to rebuild urls in another way.

Alternative solution is manually to write rewrite rules for custom component in htaccess.

Any advice?

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: sef urls for custom component, which variant is better?

Post by dam-man » Wed Mar 03, 2010 1:39 pm

I am using the normal SEF of Joomla! for my components.
Do you want to distribute the component or is it for your own use only?
If so, you can write a plugin to work with the desired SEF component as Artio. If you want to distribute, I think you should use normal Joomla! SEF, otherwise you're pushing another one to use that extention also.
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Wed Mar 03, 2010 1:47 pm

dam-man wrote:I am using the normal SEF of Joomla! for my components.
Do you want to distribute the component or is it for your own use only?
If so, you can write a plugin to work with the desired SEF component as Artio. If you want to distribute, I think you should use normal Joomla! SEF, otherwise you're pushing another one to use that extention also.
is it possible to rebuild
index.php?option=myComponent&task=viewUserDetails &userId=2456&Itemid=23

into fully SEF:
This-is-my-User-name/View-user-details.html

or partially SEF URL:
View-user-details.html?userId=2456

using joomla sef router?

Unfortunately I haven't found much documentation about how to create sef url using core joompla functions and tried to use extentions. But I wish too.

Where can I find examples of sef routers for custom components? may be you know any extention which can be revieiwed as an example?

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: sef urls for custom component, which variant is better?

Post by dam-man » Wed Mar 03, 2010 1:58 pm

devlabs wrote: is it possible to rebuild
index.php?option=myComponent&task=viewUserDetails &userId=2456&Itemid=23

into fully SEF:
This-is-my-User-name/View-user-details.html

or partially SEF URL:
View-user-details.html?userId=2456
Look at my component here, you don't an ID or URL like you have mentioned above:

The way you think Joomla is doing it:

Code: Select all

http://yourdomain.com/View-user-details.html?userId=2456  

Below my written router creating URLs like below:

Code: Select all

http://pro.rd-media.org/rd-autos-pro-20/rd-autos-support/detail/56-change-currency.html
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Wed Mar 03, 2010 7:36 pm

dam-man wrote: Look at my component here, you don't an ID or URL like you have mentioned above:

The way you think Joomla is doing it:

Code: Select all

http://yourdomain.com/View-user-details.html?userId=2456  

Below my written router creating URLs like below:

Code: Select all

http://pro.rd-media.org/rd-autos-pro-20/rd-autos-support/detail/56-change-currency.html

do I need to buy a pro version to view the code of fully functional router?

because in free version I have
/index.php/component/rdautos/?view=category&id=1
/index.php/component/rdautos/?view=detail&id=8

may be I have setuped something wrong. I disabled all sef components except core ones.

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: sef urls for custom component, which variant is better?

Post by dam-man » Wed Mar 03, 2010 8:49 pm

That's because the free version has no SEF at the moment. New version is coming with SEF. I have to restructure all links to have proper SEF url.

This will be the new Router:

Code: Select all

<?php
function RDAutosBuildRoute(&$query)
{
       $segments = array();
       if(isset($query['view']))
       {
                $segments[] = $query['view'];
                unset( $query['view'] );
       }
       if(isset($query['id']))
       {
                $segments[] = $query['id'];
                unset( $query['id'] );
       };
       if(isset($query['layout']))
       {
                $segments[] = $query['layout'];
                unset( $query['layout'] );
       };	   
	   
       return $segments;
}


function RDAutosParseRoute($segments)
{
       $vars = array();
       switch($segments[0])
       {
               case 'categories':
                       $vars['view'] = 'categories';
                       $id = explode( ':', $segments[1] );
                       $vars['id'] = (int) $id[0];					   
                       break;
               case 'category':
                       $vars['view'] = 'category';
                       $id = explode( ':', $segments[1] );
                       $vars['id'] = (int) $id[0];
                       break;
               case 'detail':
                       $vars['view'] = 'detail';
                       $id = explode( ':', $segments[1] );
                       $vars['id'] = (int) $id[0];
                       break;	
               case 'search':
                       $vars['view'] = 'search';
                       $vars['layout'] = (int) $segments[2];
                       break;						   	
               case 'sendafriend':
                       $vars['view'] = 'sendafriend';
                       $id = explode( ':', $segments[1] );
                       $vars['id'] = (int) $id[0];
                       break;						   					     					    
       }
       return $vars;
}
But it won't work on the current free version, because not all links are ready for it. Try to have this new version within 2 weeks done.
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Thu Mar 25, 2010 3:34 am

Code: Select all

	   if(isset($query['option']))
       {
                $segments[] = $query['option']; // with or without this line
                unset( $query['option'] );
       }

I use next links
echo JRoute::_( 'index.php?option=com_name&controller=new&task=build');

What can be the reason that I have
"option=com_name" replaced by "component/com_name"

insted of
/com_name/ or /name/

in sef URL ?

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Thu Mar 25, 2010 1:28 pm

may be I don't need to use option=com_name in the link but then sef doesn't work at all?

User avatar
spiderglobe
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 151
Joined: Mon Apr 03, 2006 1:45 pm
Location: Netherlands

Re: sef urls for custom component, which variant is better?

Post by spiderglobe » Thu Mar 25, 2010 2:19 pm

Small advice: use the Joomla router functionality. This is also still present within Joomla 1.6.

sh404sef is good but is not using the router functionality and sh404sef is not ready for Joomla 1.6. Artio is a very slow sef rewriter specially if you are using a lot of internal URL's.

Good news is that I'm working on a new SEF rewriter component for Joomla 1.5 and Joomla 1.6 which whereby the component automatically detects and include local component router files for the URL rewriting whereby you have the ability to remove numbers used in the URL which identifies the ID.

We will release it under the GPL license and the performance is better then the default Joomla SEF router and 50% faster then sh404sef and 200% faster then Artio.

Release will be within 2 months, also available for Joomla 1.6(!)

Note: its is storing the URL's in the database but its using an advanced caching system whereby the retrieving the URLs from the DB requires only 1 query and is actual faster then the default Joomla router once the pages are within the database.

Spiderglobe 2010.

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Thu Mar 25, 2010 3:35 pm

Yea I am using joomla core SEF which is a good thing ;)

I got an advice that if the
echo JRoute::_( $url );
doesn't have an itemID then it will add "component/com_name" to the beginning of sef URL

The component isn't using itemID at all and don't need it.(site menu and modules are disabled and done inside of the component)
How can I apply a fix for required itemID so that it wasn't required at all?


2 spiderglobe
thanks but what will you do with such pages a list of USERS?
Artio SEF has 100 sql queries on such page with enabled cache and 400 without it. The same thing with sh404.

It will be good if your component could work without sql queries even if you store all the data compresed in one variable.

User avatar
spiderglobe
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 151
Joined: Mon Apr 03, 2006 1:45 pm
Location: Netherlands

Re: sef urls for custom component, which variant is better?

Post by spiderglobe » Thu Mar 25, 2010 5:24 pm

It works also with a cache storage within the database. But it uses once the pages are loaded only 1 query to fetch the cached URL's which is very fast.

I've made serveral bench marks with jmeter and compare it to artio / sh404sef and the basic joomla sef router. In all the cased (different pages) the component is faster also faster then the core Joomla sef router since the Joomla core sef router must rewrite all urls by loading the components router files and parse these as well the component we are building is doing that from the cache.... Special on pages with a lot of URL's.....

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: sef urls for custom component, which variant is better?

Post by devlabs » Fri Mar 26, 2010 5:37 pm

I got an advice that if the
echo JRoute::_( $url );
doesn't have an itemID then it will add "component/com_name" to the beginning of sef URL

The component isn't using itemID at all and don't need it.(site menu and modules are disabled and done inside of the component)
How can I apply a fix for required itemID so that it wasn't required at all?


Locked

Return to “Joomla! 1.5 Coding”