1

I wrote a component and made a router.php by documents in Joomla.org. My problem is that how can I remove item view from URL?

For example I have this view -> musicses, now my SEF URL is like this

/music/99-2016-03-13-06-12-39/musics/3-music77.html?layout=article

I want change it like this : /music/music77.html
music77 is my title for this post,

This is my code:

http://sandbox.onlinephpfunctions.com/code/bdcb649b90aae2b415e53054be7d65448cf30493

2
  • Link to your code is not working
    – Lodder
    Apr 11, 2016 at 10:24
  • Approved the edit, but why was it made by a completely different user? Are you using 2 separate accounts? If so...any reason?
    – Lodder
    Apr 11, 2016 at 10:56

1 Answer 1

1

Take a look into the com_content router, category blog view works like that, shows a list of articles under domain.com/blog and the links are generated like domain.com/category/1-my-first-article

But it also allows something like this:

domain.com/blog/1-my-first-article

Therefore you have to change your link generating (JROUTE) in your component for the item, removing the item view. You can manually build the link to by parsing just the route to the list view, attaching the item alias to the url string.

This could be helpful too:

https://stackoverflow.com/questions/22116391/advance-url-sef-for-joomla-custom-component

(I don't do that for my components I just redirect everything to the main view and then check the segments with an external router class.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.