RE: Friendly URL multiple routes

Adrian Pol, modified 6 Years ago. Junior Member Posts: 49 Join Date: 3/14/17 Recent Posts
Hello!

i'm using Liferay 7.0 and we want to create a module with friendly url, we need create routes like this:
  • /sample/{sampleId}
  • /example/{exampleId}
  • /noob/{noobId}
With the example of Liferay (https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-0/making-urls-friendlier) all the routes is mapping by one xml and one DefaultFriendlyURLMapper, in such a way that everything would be like this:
  • /blogs/sample/{sampleId}
  • /blogs/example/{exampleId}
  • /blogs/noob/{noobId}
I¿s posible create multiples routes.xml and multiples DefaultFriendlyURLMapper clases for make it like the first example?

thank you so much community!
thumbnail
Amos Fong, modified 6 Years ago. Liferay Legend Posts: 2047 Join Date: 10/7/08 Recent Posts
Yea, should be possible. Just create multiple *route.xml files and then in your FriendlyURLMapper, you can specify different prefixes for each route.xml
thumbnail
Eric COQUELIN, modified 6 Years ago. Expert Posts: 254 Join Date: 11/3/13 Recent Posts
How ?

In Liferay, you define one function whatever the route is

@Override
    public String getMapping() {
        return _MAPPING;
    }


Unless I can define as many XXXFriendlyURLMapper as I want. Need to test.
thumbnail
Amos Fong, modified 6 Years ago. Liferay Legend Posts: 2047 Join Date: 10/7/08 Recent Posts
Yea, I think I wasn't clear in my response. You should be able to create multiple XXXFriendlyURLMapper classes in one module. For an example, look at the document-library-web module.