Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Andrew O
Site Template Questions
February 1, 2012 9:16 AM
Answer

Andrew O

Rank: New Member

Posts: 9

Join Date: January 27, 2012

Recent Posts

I am using a site template with LR 6.1 and had two questions about it. The first, if I have several sites using the template, and then I make changes to the template itself, is it possible to have those changes perpetuated to all the sites that use the template. I saw in the documentation that when a site uses a site template, it simply copies the template and does not create a link with it. However, I did notice that there was a bug filed for this issue and I was wondering if anyone knew any more information about it.

The second question is in regards to using hyperlinks within the Web Content Display portlets of a site template. I have some anchors with links inside the site template, for example moving between specific site pages of the template. But when I use the template in creating a new site, none of the links work because the url is different for the new site (localhost/group/template/page1 changes to localhost/web/company/page1). How would I remedy this issue, without going to each page and manually changing the link for each new site? Should I not be embedding anchors inside my Web Content Displays?
Nate Cavanaugh
RE: Site Template Questions
February 2, 2012 9:33 AM
Answer

Nate Cavanaugh

LIFERAY STAFF

Rank: Junior Member

Posts: 63

Join Date: November 27, 2006

Recent Posts

Hi Andrew,
About your first question, you should see a checkbox when creating a new site from a template:


If you keep that box checked, it will update your sites when you edit the Site Template (I tested this locally, and it is working for me).

About your second question, I'm not sure off the top of my head if there's an API to allow linking from within the site template, but I'll take a look and see what I can find out.

Thanks Andrew,
Nate Cavanaugh
RE: Site Template Questions
February 2, 2012 10:43 AM
Answer

Nate Cavanaugh

LIFERAY STAFF

Rank: Junior Member

Posts: 63

Join Date: November 27, 2006

Recent Posts

Hi Andrew,
Actually, I did a bit more testing and asking around, but basically, that checkbox I pointed to does not apply to content, but to the portlet itself.

I'm not 100% sure if there's a way to do exactly what you're looking for, but I'll try to see if there's a workable solution.

Thanks,
Andrew O
RE: Site Template Questions
February 3, 2012 7:33 AM
Answer

Andrew O

Rank: New Member

Posts: 9

Join Date: January 27, 2012

Recent Posts

Hi Nate,

Thanks for your responses! I appreciate you looking into this issue. For the time being, I'm just doing manual changes of links and content as needed, since there are only 2 sites that I am using the template for. However, I am hoping to expand up to 20+ in the next couple months as well as add more contents to the portlets themselves.

Thanks!
Andrew O
RE: Site Template Questions
February 20, 2012 11:25 AM
Answer

Andrew O

Rank: New Member

Posts: 9

Join Date: January 27, 2012

Recent Posts

So any new updates or workarounds in regards to this issue?
Sandrine Dullier
RE: Site Template Questions
January 25, 2013 2:15 AM
Answer

Sandrine Dullier

Rank: New Member

Posts: 3

Join Date: March 30, 2012

Recent Posts

Hi everyone,

I have the same problem for internal links in web content of a site template.

Has someone already find a turnaround ?

thanks !
Andrew O
RE: Site Template Questions
January 25, 2013 10:41 AM
Answer

Andrew O

Rank: New Member

Posts: 9

Join Date: January 27, 2012

Recent Posts

Hi Sandrine,

I used the following workaround for the links within pages. I did away with the web content portlets and instead created my own custom portlets. This is a relatively easy task and within the view.jsp of the portlet, you can actually have plain html code. I then used the settings of the portlet to create a "site" variable that I could dynamically change for each instance of the portlet. I then used that variable in constructing the hyperlink. So for example, I had a footer across all sites that had a "About" link, but the link would be different depending on what site I was on. So in the view.jsp, I had the following:

 1
 2<%@ page import="javax.portlet.PortletPreferences" %>
 3
 4     <portlet:defineObjects />
 5
 6     <%
 7          PortletPreferences preferences = renderRequest.getPreferences();
 8          String siteName = preferences.getValue("siteName", "");
 9          String siteUrl = (siteName.equals("")) ? siteName : "/" + siteName;
10     %>
11
12     <a style="color: #ffffff;" href="<%=siteUrl + "/about_us"%>">
13          About Us
14     </a>


This way, I could simply go into the Options->Configurations of each instance of the portlet when it is deployed and change the needed variable to my site name, without actually touching my code.

Just FYI, in order to implement custom configurations, you need to change the liferay-portlet.xml of the portlet to include the property configuration-action-class, as well include some custom files such as a Configuration.java and a configuration.jsp, but you can find how to do that in other parts of the forum.
Sandrine Dullier
RE: Site Template Questions
January 28, 2013 4:19 AM
Answer

Sandrine Dullier

Rank: New Member

Posts: 3

Join Date: March 30, 2012

Recent Posts

Thanks Andrew !