I need to programmatically get the default locale for a site. So I:
creata a new site with default language set to english (en_us)
create a second site with default languge set to german (de_DE)
In my code I've tried to do the following:
CompanyThreadLocal.setCompanyId(portletDataContext.getCompanyId());
final Locale locale = LocaleUtil.getDefault();
But I get "en_us" for both sites, which is the portal default locale.
I need this in my export/import functions of my PortletDataHandler implementation. Otherwise I will allways export my data with the wrong default language from staging to live.
I'm running Liferay 6.1.20 EE.
Thanks in advance, Fabi
In Liferay 6.2 you can just do:
Locale defaultLocale = PortalUtil.getSiteDefaultLocale(groupId);
Related
In Liferay 6 it was possible to get various types of links, for example you could get CreateAccount link from themeDiplay by using themeDisplay.getURLCreateAccount().toString(). Check this link
Recently I've migrated to Liferay 7. In my custom theme when I am working with .ftl files I'd like to have create account link but I can't find any suitable methods for it. Although you can find getURLSignIn() and getURLSignOut. Check this link
Is there any chance to find a create account url by themeDisplay? If not what should I do?
For theme freemaker template, you can use following.
<#assign plid = layout.getPlid()>
<#assign createAccountURL = portletURLFactory.create(request,"com_liferay_login_web_portlet_LoginPortlet",plid,"RENDER_PHASE")>
${createAccountURL.setParameter("mvcRenderCommandName", "/login/create_account")}
${createAccountURL.setParameter("p_p_state", "maximized")}
${createAccountURL.setParameter("p_p_mode", "view")}
Create Account
Use action commands in Liferay 7 to call the create account in the JSP
Example :
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/mvc-action-command
I have created a Liferay 7 module, and it works well.
Problem: In the Java source code I hard-coded something that administrators need to modify.
Question: What is the Liferay way to externalize settings? I don't mind if the server has to be restarted, but of course the ability to modify settings on a live running server (via Gogo Shell?) could be cool provided that these settings then survive server restarts.
More specifically, I have a module for which I would like to be able to configure an API key that looks like "3g9828hf928rf98" and another module for which I would like to configure a list of allowed structures that looks like "BASIC-WEB-CONTENT","EVENTS","INVENTORY".
Liferay is utilizing the standard OSGi configuration. It's quite a task documenting it here, but it's well laid out in the documentation.
In short:
#Meta.OCD(id = "com.foo.bar.MyAppConfiguration")
public interface MyAppConfiguration {
#Meta.AD(
deflt = "blue",
required = false
)
public String favoriteColor();
#Meta.AD(
deflt = "red|green|blue",
required = false
)
public String[] validLanguages();
#Meta.AD(required = false)
public int itemsPerPage();
}
OCD stands for ObjectClassDefinition. It ties this configuration class/object to the configurable object through the id/pid.
AD is for AttributeDefinition and provides some hints for the configuration interface, which is auto-generated with the help of this meta type.
And when you don't like the appearance of the autogenerated UI, you "only" have to add localization keys for the labels that you see on screen (standard Liferay translation).
You'll find a lot more details on OSGi configuration for example on enroute, though the examples I found are always a bit more complex than just going after the configuration.
Can anyone share some detailed info on how to create a Single Page Application (SPA) in Liferay 7 using SennaJS.
I could't found any documentation on How to create SPA in Liferay 7.
It comes by default, except if you unset the following property:
javascript.single.page.application.enabled=true
BTW, it is rather annoying in dev instances, as it takes a while to load pages in the first access, sometimes you even need to reload the page. Also, be aware, in some especial cases, some applications might break, normally due to code that counts with page reloads to function properly.
you can even create it in 6.2 by using the following code.
// initializing senna
var app = new senna.App();
// Set links selector for navigations
app.setLinkSelector(".senna-link");
// set basic path of liferay site
app.setBasePath('/web/spa-demo/');
// Id of DOM element which will be replaced from
// next page request
// using content div - default in liferay theme
app.addSurfaces('content');
// define routes for all the navigation links
// route link = Base path + page link
app.addRoutes([
new senna.Route('home', senna.HtmlScreen),
new senna.Route('second', senna.HtmlScreen),
new senna.Route('third', senna.HtmlScreen),
]);
Thing which you need to take care of, if it is SPA, then all the events need to be bound first i.e. delegate as there is not going to be page refresh.
i.e things like document.getReady is only going to be called once.
Whatever the portlet you are going to create and deploy with Liferay SDK/Workspace OR any compatible liferay plugin it will be SPA by default.
No need to do any coding on top of it.
I've followed following link to implement feature versioning:
http://sisharepoint.wordpress.com/2010/01/21/using-the-featureupgrading-event-to-upgrade-features-sharepoint-2010/
I am new to sharepoint and the requirement is to show the versions of features in my site. Is it possible?I am not able to see the version anywhere in the site. I can see appropriate version in the feature.xml file in feature folder of 14 hive. Just want to know that is it possible to see the versions of each deploy in sharepoint site also?If yes then where can I see it?
Thanks,
Priya
If custom solution fits your requirement then you can try following ways to find activated feature versions.
Use SPFarm.FeatureDefinitions
to get all activated features in the Farm -
SPFeatureDefinitionCollection farmFeatures = SPFarm.Local.FeatureDefinitions;
foreach (SPFeatureDefinition feature in farmFeatures)
{
....
}
To find a version of a particular feature
var spFarm = SPFarm.Local;
System.Version version = spFarm.FeatureDefinitions["YourFeatureName"].Version;
Use SPContext.Current.SiteFeatures or SPContext.Current.Site.Features
var siteFeatures= SPContext.Current.SiteFeatures;
foreach (SPFeature sf in siteFeatures)
{
variable = sf.Definition.DisplayName;
variable = sf.Definition.Version.ToString();
}
4 Use SPContext.Current.WebFeatures or SPContext.Current.Web.Features
var webFeatures= SPContext.Current.WebFeatures;
foreach (SPFeature webFtr in webFeatures)
{
variable= webFtr.Definition.DisplayName;
variable= webFtr.Definition.Version.ToString();
}
Hope this helps.
There's no way to see this in Central Admin or Site Settings. The point is to abstract away versioning from users. Users just know that a specific feature is available, not what version. I agree that it would be nice to actually be able to see this info without having to write a custom solution.
When I create a new sharepoint site collection, is there some way I can automatically set the regional settings to my local settings as part of the creation process? In particular, I want to set the default date/time format to be non-US.
Thanks
using code, you should check out the RegionalSettings of the SPWeb. For example, this would set it to UK (I've done this in on a Custom Site Definition):
CultureInfo cultureInfo = new CultureInfo("en-GB");
web.RegionalSettings.LocaleId = (uint)cultureInfo.LCID;
web.Update();