I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)> for get a records.
Old code:
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
<#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>
<#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >
It doesn't work.
So I try <#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]> but staticUtil get an error.
The following has evaluated to null or missing:
==> staticUtil [in template "20115#20159#21387" at line 9, column 27]
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing
In portal-ext.properties I have added:
freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=
The properties you refer to have been moved to an OSGI config in Liferay 7/DXP.
To deploy them you need to create a file named com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg and place it under $LIFERAY_HOME/osgi/configs
The content of the file will be the following:
restrictedVariables=
To find all the configs and their defaults you can have a look at the class com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration
That you can find in the Liferay source code.
I think those properties in portal-ext.properties are just ignored in liferay 7.
You can admin those properties in Control Panel → Configuration → System Settings → Foundation → FreeMarker Engine and remove "staticUtil" (or remove "serviceLocator" directly) from restricted variables. (liferay reboot is required)
Go to Control Panel -> System Settings -> Foundation Page
Find FreeMarker Engine from list click on it .
Remove serviceLocator variable and staticUtil from restricted variables by Clicking on (-) icon.
If you want to use staticUtil object then also remove this variable from restricted variables.
Save it.
Restart Liferay server.
You will direct access to serviceLocator object in your Application Display Template.
In liferay 7.1. you will find Freemaker Engine under
Control Panel -> System Settings -> Platform -> Template Engines
In liferay-ce-portal-7.1.1.2-ga3 version, the file is renamed to
com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.config
Related
I am migrating from liferay 6.2 to liferay 7 ,here I am getting problem to give the selected list of categories in the form.
Ex:
In the site settings by default we can able to see four different categories and its sub-categories in the form.
which are defined in the portal.properties in the following way
sites.form.update.main=details,categorization,site-url,site-template
sites.form.update.seo=sitemap,robots
sites.form.update.advanced=default-user-associations,staging,analytics,content-sharing,recycle-bin
sites.form.update.miscellaneous=custom-fields,display-settings
1)Basic Information
a)details, b)categorization, c)site-url, d)site-template
2)Search Engine Optimization
a)sitemap, b)robots
3)Advanced
a)default-user-associations, b)staging,analytics, c)content-sharing, d)recycle-bin
4)Miscellaneous
a)custom-fields, b)display-settings
We can include only some specified selected categories based on the role.
In liferay 6.2 we can avhive this by defining in the
portal-ext.properties like the below
#These custom properties are defined for portal admin
sites.form.update.main.admin=details,categorization,site-url,site-template
sites.form.update.seo.admin=sitemap,robots
sites.form.update.advanced.admin=default-user-associations,staging,analytics,content-sharing,recycle-bin
sites.form.update.miscellaneous.admin=custom-fields,display-settings
#These custom properties are defined for portal site admin
sites.form.update.main.siteadmin=details,site-url
sites.form.update.seo.siteadmin=
sites.form.update.advanced.siteadmin=recycle-bin
sites.form.update.miscellaneous.siteadmin=
But How could I achieve the same functionality in Liferay7 ?
I am using WebSphere Portal 8.5 Enable. I have created a custom theme. But this theme requires to hide pages on navigation which has unique name with ".omit." value in it, so that I don't have to manually set each page's parameter.
I created the flyout or menu dropdown using this:
Flyout or Menu Dropdown in Portal 8 themes
Any suggestions and pointers are welcome. Thanks in advance.
Maybe you have already thought about this.
The solution you mentioned (Flyout or Menu Dropdown in Portal 8 themes) hides nodes based on the hidden flag. This method is used to calculate it. Now you could query the uniquename of the Node witin this method and check for your naming pattern and use this to determine if it is hidden. It would allow you to combine the two as well.
the method I think you need to modify.
public boolean isHiddenPage(NavigationNode node){
if (node instanceof com.ibm.portal.MetaDataProvider) {
com.ibm.portal.MetaData iMetaData=((com.ibm.portal.MetaDataProvider) node).getMetaData();
Object url=iMetaData.getValue("hide.from.menu");
return (url != null && url.toString().equals("true"));
}
return false;
}
You can hide any page using the role settings just create a user group which is never used and make that the only thing that can access the page. You should be able to do this is your PAA's PageAssignAccessControl.xml (could be slightly wrong about the name of this file) as well as in the portal Admin console, so you can do it automatically in your deployment code.
In Liferay, under Control Panel -> Server Administration, we can set the file size upload limit. This overrides the
dl.file.max.size
setting in portal-ext. Can I disable the control panel from overriding this property?
Cause I want to use a seperate instance that has no upload size limit. If I'm not wrong the setting in the control panel applies to all instances connected to the same database.
We can find the setting in the liferay database table
select * from [liferay].[dbo].[PortalPreferences] where preferences like '%dl.file.max.size%';
We will get something like below:
<portlet-preferences>
.....
<preference>
<name>dl.file.max.size</name>
<value>104857600</value>
</preference>
<preference>
<name>com.liferay.portal.upload.UploadServletRequestImpl.max.size</name>
<value>524288000</value>
</preference>
.......
</portlet-preferences>
We just remove the above 2 preferences and we can set them in portal-ext.properties instead.
Liferay 6.2 CE
How exactly can one go about to set a portlet to show up on the highlighted category on the add application panel? I've been searching for hours, without any luck.
Have tried to define category name as "Highlighted", but it just creates a new one with the same name.
The main goal is just to have my own portlets sit on the top of the rest.
Cheers.
Configure the following settings (here with the defaults) in your portal-ext.properties:
##
## Dockbar Portlet
##
#
# Set the portlet ids that will be shown directly in the "Add Application"
# menu.
#
dockbar.add.portlets=56,101,110,71
Here you see that Liferay has the habit of numbering all the core portlets. Your own portlets ids will be constructed from their plugin name and the portlet id, e.g. the AmazingApp portlet that is deployed in the webapplication my-great-custom-plugins-portlet will have an ID of *amazingapp_WAR_mygreatcustompluginsportlet* (or similar). How can you find this out by yourself? Add it to the page, then choose "Look and Feel" and "Advanced Styling" - this will show the HTML id for your portlet, of which you can easily extract the actual portlet ID to use for portal-ext.properties.
I'd like to use custom fields to display some page specific strings in the theme.
I have created a custom field "intro" of type Textbox.
How do I access the data in the theme template (velocity)?
As there is no "introspection" which variables are declared, I find it very difficult to figure out how to access them. The documentation is far from usable on the topic of custom fields :-/
If you definde custom attribute in a page than you can use
$layout.getExpandoBridge().getAttribute("intro")
Also see javadoc or source for com.liferay.portlet.expando.model.ExpandoBridge
if you need use in template FTL, in my case for menu navigation template
<#assign prop = navItem.getLayout().getExpandoBridge().getAttribute("prop_name") >
Work for me in Liferay 7+:
Create a custom field type "site", fill data into site settings, and use into theme template for call this data into liferay theme:
If a VM file:
#set ($site_custom_field = $layout.getGroup().getExpandoBridge().getAttribute("site_custom_field_key"))
<h1>$site_custom_field</h1>
If a FTL file:
<#assign site_custom_field = layout.getGroup().getExpandoBridge().getAttribute("site_custom_field_key")>
<h1>${site_custom_field}</h1>
Have a nice day!