4

I have just changed the url of blogs(default) portlet to "http://localhost:8080/web/standorman/blogs/-/blogs/application-development-in-liferay"

But i want to it to be "http://localhost:8080/web/standorman/blogs/application-development-in-liferay"

Can anyone suggest me how can i solve it??

Milople Inc
  • 399
  • 1
  • 8
  • 34

3 Answers3

1

First, you can't get rid of /-/ without really hacking into Liferay which you don't want to do (it will cause much more problems than benefits). All you can get rid off is one "blogs", ending with URL like /web/standorman/-/blogs/application-development-in-liferay - which seems close enough for me.

Here's how you can use https://github.com/DevJonny/Liferay-6-Friendlier-Friendly-URL-Mapper/ suggested by yannicuLar to do that.

His suggestion doesn't work for you just like that because you're trying to change an out-of-the-box Liferay portlet that's embedded in Liferay itself. To change things like that one has to use an EXT plugin. So this is exactly what you should do.

Step 1 - create an EXT plugin in Plugins SDK (by running create.bat or create.sh in plugins SDK "ext" subfolder).

Step 2 - go inside created ext plugin folder, in /docroot/WEB-INF/ext-impl/src delete file portal-ext.properties, and instead put this file - https://github.com/DevJonny/Liferay-6-Friendlier-Friendly-URL-Mapper/blob/master/docroot/WEB-INF/src/com/mysmallcornerstudios/friendlierurlmapping/portlet/FriendlierFriendlyURLMapper.java into it to have it at path

/docroot/WEB-INF/ext-impl/src/com/mysmallcornerstudios/friendlierurlmapping/portlet/FriendlierFriendlyURLMappe r.java

Step 3 - open file docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml Fill it with content like this:

<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd">

<liferay-portlet-app>

    <portlet>
        <portlet-name>33</portlet-name>
        <icon>/html/icons/blogs.png</icon>
        <struts-path>blogs</struts-path>
        <configuration-action-class>com.liferay.portlet.blogs.action.ConfigurationActionImpl</configuration-action-class>
        <indexer-class>com.liferay.portlet.blogs.util.BlogsIndexer</indexer-class>
        <open-search-class>com.liferay.portlet.blogs.util.BlogsOpenSearchImpl</open-search-class>
        <scheduler-entry>
            <scheduler-event-listener-class>com.liferay.portlet.blogs.messaging.CheckEntryMessageListener</scheduler-event-listener-class>
            <trigger>
                <simple>
                    <property-key>blogs.entry.check.interval</property-key>
                    <time-unit>minute</time-unit>
                </simple>
            </trigger>
        </scheduler-entry>
        <scheduler-entry>
            <scheduler-event-listener-class>com.liferay.portlet.blogs.messaging.LinkbackMessageListener</scheduler-event-listener-class>
            <trigger>
                <simple>
                    <property-key>blogs.linkback.job.interval</property-key>
                    <time-unit>minute</time-unit>
                </simple>
            </trigger>
        </scheduler-entry>
        <friendly-url-mapper-class>com.mysmallcornerstudios.friendlierurlmapping.portlet.FriendlierFriendlyURLMapper</friendly-url-mapper-class>
        <friendly-url-mapping>blogs</friendly-url-mapping>
        <friendly-url-routes>com/liferay/portlet/blogs/blogs-friendly-url-routes.xml</friendly-url-routes>
        <preferences-unique-per-layout>false</preferences-unique-per-layout>
        <preferences-owned-by-group>true</preferences-owned-by-group>
        <use-default-template>false</use-default-template>
        <scopeable>true</scopeable>
        <private-request-attributes>false</private-request-attributes>
        <private-session-attributes>false</private-session-attributes>
        <render-weight>50</render-weight>
        <header-portlet-css>/html/portlet/blogs/css/main.css</header-portlet-css>
        <css-class-wrapper>portlet-blogs</css-class-wrapper>
        <add-default-resource>true</add-default-resource>
    </portlet>
</liferay-portlet-app>

This content is correct for my version of Liferay. For your version you might need to do this to generate similar content:

  • Inside your Liferay distribution find file liferay-portlet.xml (should be in webapps/ROOT/WEB-INF for Tomcat-bundled distro, but maybe in different location for other distress - just search for it)
  • Inside that file find <portlet>...</portlet> part that has <portlet-name>33</portlet-name> in it
  • Copy the whole part inside <liferay-portlet-app><!-- copied text goes here --></liferay-portlet-app> to mentioned above file docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml inside your EXT plugin.
  • Replace line <friendly-url-mapper-class>...</friendly-url-mapper-class> with <friendly-url-mapper-class>com.mysmallcornerstudios.friendlierurlmapping.portlet.FriendlierFriendlyURLMapper</friendly-url-mapper-class>
  • Remove lines

``

<portlet-data-handler-class>com.liferay.portlet.blogs.lar.BlogsPortletDataHandlerImpl</portlet-data-handler-class>
<social-activity-interpreter-class>com.liferay.portlet.blogs.social.BlogsActivityInterpreter</social-activity-interpreter-class>
<xml-rpc-method-class>com.liferay.portlet.blogs.util.PingbackMethodImpl</xml-rpc-method-class>
<asset-renderer-factory>com.liferay.portlet.blogs.asset.BlogsEntryAssetRendererFactory</asset-renderer-factory>
<atom-collection-adapter>com.liferay.portlet.blogs.atom.BlogsEntryAtomCollectionAdapter</atom-collection-adapter>
<custom-attributes-display>com.liferay.portlet.blogs.BlogsEntryCustomAttributesDisplay</custom-attributes-display>
<workflow-handler>com.liferay.portlet.blogs.workflow.BlogsEntryWorkflowHandler</workflow-handler>

Step 4 - deploy your ext plugin (run ant inside it's folder to build it, go up to subfolder "dist" in Plugins SDK, find .war file for your plugin - deploy that .war file into Liferay by copying it to "deploy" folder inside Liferay distrib) and restart Liferay.

That should do it.

mvmn
  • 3,717
  • 27
  • 30
0

Maybe adding a custom FriendlyURL Mapper class to disable that '-' prefix. Have you tried this ?

I'm really sorry I could help giving a working example. I gave it a good try, as I'm interested too for that feature, but I'm afraid that this isn't possible at least for liferay 6.1.0. Looks like the '/-/' is necessary for friendly urls. The solution that I found and proposed is actually a hack, and I do believe that given some limitation it might work, but even if you manage to implement it, you can't be sure it will work for all liferay versions.

as requested I'm posting the steps detailed here, although I have to say that this didn't work for me (the Custom Mapper throws error while creating the friendlyUrl)

  1. You should already have done a friendly mapping with at least one route and using the DefaultFriendlyURLMapper. If you see the '/-/' char in your url, you know it works. Remember this url, you'll need it to test later, as you are sure that the Friendly -url kicks in for this route
  2. create a custom MApper class that extends the DefaultFriendlyURLMapper

        public class DemoCustomFriendlyUrlMapper extends DefaultFriendlyURLMapper {
    
    @Override
    public boolean isCheckMappingWithPrefix() {
    
        return false;
    }
    

make sure to get your Class qualified name (in Eclipse press F2 while hovering over the class Name)

  1. go to liferay-portlet.xml and replace

    <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
    

with

<friendly-url-mapper-class>com.liferay.samples.DemoCustomFriendlyUrlMapper</friendly-url-mapper-class>

go and Navigate to the url that gets friendly-routed and see what happens.

yannicuLar
  • 3,083
  • 3
  • 32
  • 50
  • 1
    Yes i have worked on this, but it doesn't show up any result. If you can will you provide me the complete steps for the same. – Milople Inc Mar 09 '13 at 04:29
  • What do you mean by saying 'doesn't show up any result' ? You get no Friendly Url ? or a Friendly url with the prefix still there ? sAre there any runtime errors ? If you've managed to make a normal friendly URL, the prefix removal is pretty straightforward.. – yannicuLar Mar 12 '13 at 10:02
  • 1
    The url shows up the same with the same prefix. Can you provide me the steps for this friendly-url mapping?? – Milople Inc Mar 14 '13 at 10:26
0

Create a url-mapping.xml file in your resources. Add the below entry in the file:

/{value} ----- try without "/view/" your resource name 2 cacheLevelPage

Also,you need to add the below piece of code in your liferay-portlet.xml. .....after icon com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper your resource name which will map your url /urlMapping/you url-mapping.xml name ....

In my case,I created a resource,basically a hyperlink on which a new page with a friendly url.

I hope this will help.Good luck

PanwarS87
  • 319
  • 5
  • 14