I am trying to use serviceLocator in the velocity template for journal article in Liferay.
I modified the portal-ext.properties file by adding line:
journal.template.velocity.restricted.variables=
Then i restarted the server
In my vm file I have:
#set ($countryService = $serviceLocator.findService("com.liferay.portal.service.CountryService"))
#set ($countryList = $countryService.getCountries())
#foreach ($country in $countryList)
$country.getName()
#end
This displays nothing in the article and also gives no error on the server. I also checked the database and countries are there and if I am using getCountries() method in my portlets service it returns countries as it should.
Has anybody had a similar problem ?
I figured out what I was doing wrong.
In the portal-ext.properties firstly I was setting:
journal.template.velocity.restricted.variables=
But instead that, it sholud be:
velocity.engine.restricted.variables=
Related
I know how to get groupid in liferay velocity theme using:
#set ($scopeGroupId = $getterUtil.getLong($group_id))
However I also need to get a folder's ID using its name.
I have been researching for a while and don't seem to find a way to do that.
Q: Is this enabled and feasible in liferay 6.2?
Make sure that you are allowed to use serviceLocator or add in your portal-ext.properties this entry:
velocity.engine.restricted.variables=
After that you can use this code in your template:
#set ($folderLocalService =$serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFolderLocalService"))
#set ($folderId = $folderLocalService.getFolder($groupId,0,"folder_name").getFolderId())
$folderId
Or you can use another method from DLFolderLocalService.
Right now I am using the default portal_normal.vm to display my page. I have made some changes to custom.css to give some look to the theme (JUst changed the colour of the background)
I have made some changes to the portal_normal.vm.
What if I want to give a complete different look to my page ? My answer is make changes to the portal_normal.vm page.
MY question is :
portal_normal.vm has some variables and stuff like:
<html class="$root_css_class" dir="#language ("lang.dir")" lang="$w3c_language_id">
I would like to know where does portal_normal.vm get these values from? By values I mean values of variables like $root_css_class ? Usually velocity gets these values from a java class. So in liferay theme, from where does portal_normal.vm get these values from? Is it ok to change the portal_normal.vm file completely?
Yes you can change any thing in portal_noraml.vm file and you design your own look.
Here to change portal_normal.vm we will use theme. in _diff/templates place classic theme portal_normal.vm and do changes.
All velocity variable are declared in init.vm file and we have another file called inti_custom.vm for declare our own velocity related variables.
Most of the velocity variables which required for portal already defined by liferay people we just use those.
Use init_custom.vm in _diff/templates folder for custom velocity varibles.
https://github.com/liferay/liferay-portal/blob/6.2.x/portal-web/docroot/html/themes/_unstyled/templates/init.vm
Most of the variables already loaded by velocity engine so max we dont need to create new variables in velocity engine.
You can create theme in liferay and provide customization in portal_normal.vm.
There is init.vm file where some of the variables are declared and also VelocityVariablesImpl.java is the class where vm variables are defined.
I built a component in joomla 2.5 (back end) and even if I don't include code for pagination, my results aren't displayed fully (they are limited to about 20). Is there a way where I can have all my results show on default? Or in other words disable pagination? Thanks!
In your list model, set the list.limit state accordingly. By default it will use the global list limit.
You can use this code in the populateState() function:
$this->setState('list.limit', 0);
Please note that if you call parent::populateState($order, $dir);, this will also set the list.limit. So you either don't call the parent function or your set the state after the parent function was called.
firstly open your custom component view file, which is located in
/components/component_name/views/tmpl - file name is default.php and now comment this line
<?php echo $this->loadTemplate('_header'); ?>
and also
<?php echo $this->loadTemplate('_footer'); ?>
may very much help!
or another way is that goto joomla administrato - site - globle confi - Default List Limit
change limit
How can I get the title of current page in a CMS velocity template ?
I need the same String as is shown in the last part of the breadcrump, in other words, the page title.
Finally I found out how to do it.
It's necessary to access through the $themeDisplay
##Take layout id
#set ($layoutId = $request.get("theme-display").get("plid"))
## get the service for layout
#set($layoutService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
##convert the layout id into long
#set ($layoutLong = $getterUtil.getLong($layoutId))
##take a layout object
#set($layout = $layoutService.getLayout($layoutLong))
#set ($pageName = $layout.getName($locale))
That's it.
In a theme template: $page.getHTMLTitle($locale)
From a CMS template I'll have to dig a bit deeper for the answer... let me know if the theme is sufficient
In addition with larrytron code, It's usefull to declare this line in portal-ext.properties to use restricted variables in CMS Template
journal.template.velocity.restricted.variables=
I have 2 sites running on my magento platform.
For site2, I added new fields to the registration page and it works properly.
Now, I noticed that when I try to register in site1, on submit I am shown a validation message that the additional fields I have added for site2 are required.
How do I make sure that the additional fields added for site2, are asked only for site2 and not site1?
I have separate themes for both site1 and site2 and both of them have separate register.phtml files.
In the config.xml file for adding custom registration fields, I have this added:
<customer_account>
<employee_id>
<create>1</create>
<update>1</update>
</employee_id>
<doj>
<create>1</create>
<update>1</update>
</doj>
<mobile_number>
<create>1</create>
<update>1</update>
</mobile_number>
<alternate_mail>
<create>1</create>
<update>1</update>
</alternate_mail>
</customer_account>
which is under <global> tag. I assume Magento is reading this. How do I make sure magento reads this config file for a particular site/store? Thanks.
If you want to see the entire XML tree magento has compiled from all XML configuration files:
header("Content-Type: text/xml");
die(Mage::app()->getConfig()->getNode()->asXML());
Will present you with a single compiled XML of their entire tree, this may help in determining if your changes are being added.
Also be sure and checkout Alan Storms CommerceBug as it has this functionality built-in.
How I solved a similar situation is that I added system configuration options to allow me to set which custom field is enabled all the way down to the store view scope. This means I don't need to have separate phtml for the different stores, but can just use the same.
I've also created custom phtml 'widgets' - modelled on the Magento DOB, Gender and Name widgets. The custom widget block code has a 'isEnabled()' method that checks the config flag. In, say, my checkout/onepage/billing.phtml I can say:
<?php $_mywidget = $this->getLayout()->createBlock('mycompany/customer_widget_mywidget') ?>
<?php if ($_mywidget->isEnabled()): ?>
....
<?php endif ?>
Hope this helps.