Menu Content

Podpora

> Diskusní fóra, FAQs & placená podpora
Welcome, Guest
Username Password: Remember me

sef urls for custom component, what is better?
(1 viewing) (1) Guest
Support forum for users using free edition of JoomSEF 3 (Joomla 1.5 compatible). These forums are mainly for mutual help between users.

Please note that due to our capacity limitations, we do not monitor these forums regularly.
  • Page:
  • 1

TOPIC: sef urls for custom component, what is better?

sef urls for custom component, what is better? 14 years, 8 months ago #10972

  • devlabs
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?
Last Edit: 14 years, 8 months ago by .

Re:sef urls for custom component, what is better? 14 years, 8 months ago #10974

  • jaku
Hello,

JoomSEF can handle both way, so you can either:
1. have a JoomSEF extension that provides ANY format of URLs, but it stores them to DB
or
2. have a Joomla-style router for your component, which does not store URLs for the component to DB and transles them automatically back and forth, however, such URLs have a limitations and special conditions, such as they need to include all needed variables (which can be "hidden" if URL is stored to DB), format that can be automatically converted to original non-SEO URL, etc.

The first case creates additional queries to DB which increases the DB load (however, JoomSEF caching on the other hand attepts to descreate that load). The second then take CPU resource at the webserver, needed to do the on-fly translations (so if those are quite complex, it may even be more demanding that the DB query).

So the decision depends on several factors, such as:
1. number of links the component generates
2. complexity of component's links (sometimes these can be largely simplyfied with good component design)
3. need of additional JoomSEF features that only work when DB storage is used, such as custom meta data, page titles, etc.

The basic handling option can be set in the Manage Extensios section of JoomSEF, where you choose among
1. JoomSEF default handler (storing URLs to DB)
2. own component router (automatic on-fly translations, but limited features)
3. none SEF URLs

Now, explicitelly to your questions:
Q: Is that the principle of it’s work, to store everything in db and then just to replace?
A: Yes, that is how extensions for JoomSEF work, so you can use all its functinality, that is not available without storing the data to DB.

Q: Or it’s because I haven’t written custom extention for my component?
A: Exactly so, if a special extension for the component does not exists, JoomSEF will try to suggest the SEF URLs using its default handler, but that is usually not satsfactory for more complex custom extensions. Then a special extension should be created.

I hope this explains how it works and gives answers to your questions.

Re:sef urls for custom component, what is better? 14 years, 8 months ago #10976

  • devlabs
1. I don't need
additional JoomSEF features that only work when DB storage is used, such as custom meta data, page titles, etc.


I need only sef urls.

Don't know the reason but cache file wasn't created on localhost. I set the minimum hits to 1 but still a cache folder was created but no cache file.

\www\components\com_sef\cache

may be cache file is hidden elsewhere.



2. If to choose between
- "component router"
- manually written rewrite relus in htaccess

Will there be any advantages of "component router" over hardcoded htaccess ?

(just example)
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 [L]

in average url has 2-3 identifier

3. thanks for reply
Last Edit: 14 years, 8 months ago by .

Re:sef urls for custom component, what is better? 14 years, 8 months ago #10980

  • jaku
ad 1) cache file is stored in /cache (in Joomla root dir)

ad 2) in funcitonality there is no real difference, the only difference is whether you want to do it in accordance with Joomla API or not; also the solution with .htaccess would be problematic to change in later phases and it is not possible to easily switch it off, because your component will have to generate already SEFed URLs right away
- I would certainly decide to use the solution using a router

Re:sef urls for custom component, what is better? 14 years, 8 months ago #11290

  • devlabs
in Router.php of the customcomponent

      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 ?

thanks

Re:sef urls for custom component, what is better? 14 years, 8 months ago #11326

  • devlabs
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?
  • Page:
  • 1
Přihlášení uživatele Prázdný