Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:08:53+00:00 2026-06-03T07:08:53+00:00

I have custom Joomla(v1.5) component and currently working with component’s router. The problem is

  • 0

I have custom Joomla(v1.5) component and currently working with component’s router. The problem is I can’t remove id numbers from SEF url. I get:

http://myaddress.com/componentalias/17-city-alias/130-item-alias

What I want to get:

http://myaddress.com/componentalias/city-alias/item-alias

Take a look at router.php methods below:

function ComponentnameBuildRoute(&$query) {

    $segments = array();

    if(isset($query['city_id'])){               
        $segments[] = $query['city_id'];                    
        unset($query['city_id']);
    }

    if(isset($query['item_id'])){
        $segments[] = $query['item_id'];          
        unset($query['item_id']);
    }


    if(isset($query['task'])){
        switch($query['task']){
            case 'pay':
                $segments[] = JText::_('payment');
                unset($query['task']);
                break;  
        }
    }

    unset($query['view']);

    return $segments;
}
/*
 * Function to convert a SEF URL back to a system URL
 */
function ComponentnameParseRoute($segments) {

    $var = array();

    if(isset($segments[0])){
        $cityData = explode(':',$segments[0]);
        if(isset($cityData[0])){
            $vars['city_id'] = $cityData[0];
        }
    }

    if(isset($segments[1])){
        $itemData = explode(':',$segments[1]);
        if(isset($itemData[0])){
            $vars['item_id'] = $itemData[0];
        }
    }

    if(isset($segments[2])){
        switch($segments[2]){
            case JText::_('payment'):
                $vars['task'] = 'pay';
                break;  
        }
    }


    return $vars;

}

Any ideas? Your help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:08:55+00:00Added an answer on June 3, 2026 at 7:08 am

    The best place to start with your router.php file is reading this article (it’s a bit dated but still good) and then reviewing the com_content’s router.php file (components/com_content/router.php). You will notice that articles do achieve what you want so best to look at working code and got from there.

    Longer answer:

    1. You can only get rid of the item ID variables in a path to a content element if a menu item exists that points directly to the item, otherwise there is no way to find the item.

    2. SEF URLs in Joomla! 1.5 etc are made from the alias’ of the individual elements

    eg. If I have this menu structure:

    Recipes                (The menu)
    -- Seafood             (<-- Category blog where category alias is `seafood` )
      -- Grilled Snapper      (<-- Recipe Item where item alias is `grilled-snapper` )
    -- 'Other category'    (<-- Another Category blog )
    

    Full ID Removal

    In the case where you’re building the SEF URL for a recipe you can build the route by looking for the menu item it might appear in by getting the site menu $menu = &JSite::getMenu(); and comparing the query id in the current menu item against id value in the $query array passed in.

    If you have a match you can build the segments up using the alias from the menu path and the recipe alias. (And reverse the process in your ParseRoute($segments) method).

    So, from this example above you could build a SEF URL to the Grilled Snapper recipe that looks something like: recipes/seafood/grilled-snapper.

    Partial ID Removal

    Now say you also have another recipe (e.g. ‘Garlic Prawns’ alias garlic-prawns) that isn’t directly linked to a menu but will appear in the ‘Seafood’ category blog page. In this situation you would end up with recipes/seafood/2:garlic-prawns

    If you don’t have a match (like the Garlic Prawns), you can build up partial match if your component has list views like category blogs or in our example Recipe category pages… Essentially in this case you look at the current menu item and determine if it’s a list/category view that would contain the content item.

    If it is then the path to the category/list view form you initial segments, but as there is no menu item for the article you will still have to use the ID of the item in the last element of the URL.

    No Menu Item for content item or a list/category view

    When the content item is being linked to directly (e.g. from an article, module or search result) and there are no menu items that point to it or could contain it then you can still create a URL without id’s in it but you will be providing the path in the form of direct component access URL.

    eg. /component/recipes/recipe/ice-cream-sundae where recipes is the name of the component, recipe is the view and ice-cream-sundae is the alias of the article.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom Joomla component and a router for building my SEF URL's
I have custom component that I can place in my layout file (XML) for
I have generated an rss feed in my custom component in my joomla site.
I have custom coded Joomla v1.5 component. In administrator zone I change its parameters,
I'm using Joomla 1.5. I have created a custom component that pulls data out
I develop a custom joomla 1.5 component and it's working fine locally(wamp server ,php
I am using Joomla 1.5 . I have developed a custom component that's basically
I am working on a custom Joomla MVC component. My view has a form
Hi I have a bit of a problem. I have written a custom component
I have a custom component I'm working on and I'm writing an import script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.