フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Abhi Ed
database call in navigation.vm
2012/07/17 1:19
答え

Abhi Ed

ランク: Regular Member

投稿: 118

参加年月日: 2012/06/04

最近の投稿

hello,
In my theme i have a requirement that one of the navigation links will contain the list that will be dynamically populated after querying the database.
Can we make a database call in navigation.vm ?
Muzakir Khan
RE: database call in navigation.vm
2012/07/17 3:02
答え

Muzakir Khan

ランク: Regular Member

投稿: 112

参加年月日: 2012/03/14

最近の投稿

Abhi Ed:
hello,

Can we make a database call in navigation.vm ?

Think so yes, we can make a database call in navigation.vm using javascript..

Regards
Khan
Abhi Ed
RE: database call in navigation.vm
2012/07/17 3:05
答え

Abhi Ed

ランク: Regular Member

投稿: 118

参加年月日: 2012/06/04

最近の投稿

Muzakir Khan:
Abhi Ed:
hello,

Can we make a database call in navigation.vm ?

Think so yes, we can make a database call in navigation.vm using javascript..

Regards
Khan


Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?
Muzakir Khan
RE: database call in navigation.vm
2012/07/17 3:14
答え

Muzakir Khan

ランク: Regular Member

投稿: 112

参加年月日: 2012/03/14

最近の投稿

Abhi Ed:

Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?


I am sorry, you have to include the javascript code(onclick) for calling the database in your portal_normal.vm of your theme..
You just google javascript code for the same, u will get it..
Abhi Ed
RE: database call in navigation.vm
2012/07/17 3:52
答え

Abhi Ed

ランク: Regular Member

投稿: 118

参加年月日: 2012/06/04

最近の投稿

Muzakir Khan:
Abhi Ed:

Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?


I am sorry, you have to include the javascript code(onclick) for calling the database in your portal_normal.vm of your theme..
You just google javascript code for the same, u will get it..



I don't know, how practical ur solution is,Muzakir.However,thanks for ur time.

The question stands open yet.If anyone has done like this before,please share ur ideas.
Priyanka Dhingra
RE: database call in navigation.vm
2012/07/17 8:23
答え

Priyanka Dhingra

ランク: Liferay Master

投稿: 501

参加年月日: 2011/12/19

最近の投稿

Hi,
Please check the following link
https://www.liferay.com/community/forums/-/message_boards/message/10559868
I think editing the velocityvariable class will give you access to your database and then you can access the variable with a $ in your init-custom.vm
I didnt tried anyways but that can be a possible solution(an idea).
Aravinth Raj Raju
RE: database call in navigation.vm
2012/08/14 3:30
答え

Aravinth Raj Raju

ランク: Junior Member

投稿: 27

参加年月日: 2011/10/03

最近の投稿

Hi,

I too have similar requirement, to load menus after querying from a custom table.
Plz post your ideas.

Thanks,
Aravinth Raj R.
David H Nebinger
RE: database call in navigation.vm
2012/08/14 6:09
答え

David H Nebinger

Community Moderator

ランク: Liferay Legend

投稿: 13258

参加年月日: 2006/09/01

最近の投稿

Abhi Ed:
Can we make a database call in navigation.vm ?


Yes, although you shouldn't do things this way.

Navigation.vm is a velocity script, and tweaking the velocity context to include necessary stuff to run the query would not be good.

Instead you should wrap the logic into a Spring bean. Register the bean in the portal's Spring context, then use $utilLocator.findUtil("my spring bean") to get access to the spring bean in navigation.vm, call the bean, and handle the results.

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!