Link to page not working liferay 6.2 web content template

997 views Asked by At

I have created a site template in Liferay6.2, in that site template, I have created a structure and template, in that I used link to page. The code for the link to page is as follows:

<a href="$Link_to_Page2163.getFriendlyUrl()">Create Project</a>

Here is the full code of the web-content template:

#if (!$scrom_image.getSiblings().isEmpty())
    #foreach ($cur_scrom_image in $scrom_image.getSiblings())
    <div id="scrommaindiv">
        <center>
            <div class="scrom_img"><img alt="scrom_image" src="$cur_scrom_image.getData()"/></div>
                <h3>
                    <a href="$cur_scrom_image.Link_to_Page2163.getFriendlyUrl()">$cur_scrom_image.scrom_head.getData()</a>
                </h3>
            <div class="scrum_desc">$cur_scrom_image.scrom_desc.getData()</div>
        </center>
    </div>

    #end
#end

When I created the organization by using the site template, the links are not working, still in the links it is showing site template id.

Example: in inspect elements i found the link like this

<a href="http://vidyayugscrum.buildyourcareerpath.com:7080/group/template-39711/my-project" id="yui_patched_v3_11_0_1_1434085215630_420">Create Project</a>

In created organization after changing the links its working fine, but what I want is when I create organization, in the created organization the links should work perfectly. for example :

<a href="http://vidyayugscrum.buildyourcareerpath.com:7080/group/my-project" id="yui_patched_v3_11_0_1_1434085215630_420">Create Project</a>

How do I achieve this with velocity code?

1

There are 1 answers

0
Celtik On

Try this code in your velocity template:

#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#set ($linkPage = $cur_scrom_image.Link_to_Page2163.getFriendlyUrl().split("@"))
#set ($pageLayout = $layoutLocalService.getLayout($getterUtil.getLong($linkPage.get(2)), false, $getterUtil.getLong($linkPage.get(0))))
#set ($pageURL = $pageLayout.getFriendlyURL())

#if (!$scrom_image.getSiblings().isEmpty())
  #foreach ($cur_scrom_image in $scrom_image.getSiblings())
  <div id="scrommaindiv">
      <center>
          <div class="scrom_img"><img alt="scrom_image" src="$cur_scrom_image.getData()"/></div>
              <h3>
                  <a href="$pageURL">$cur_scrom_image.scrom_head.getData()</a>
              </h3>
          <div class="scrum_desc">$cur_scrom_image.scrom_desc.getData()</div>
      </center>
  </div>

  #end
#end

I hope it helps! ;)