構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
pawan chauhan
Images/Icons in Navigation Bar
2012/11/15 0:47
答え

pawan chauhan

ランク: Junior Member

投稿: 75

参加年月日: 2012/10/08

最近の投稿

Hi All,
I am using liferay 6.1.
I am trying to put images in place of text in the navigation bar for the pages that i have added.
Can anyone please guide me how to do this.

Regards,
Pawan chauhan.
Oliver Bayer
RE: Images/Icons in Navigation Bar
2012/11/15 0:53
答え

Oliver Bayer

ランク: Liferay Master

投稿: 889

参加年月日: 2009/02/18

最近の投稿

Hi Pawan,

if you want to customize the menu create a custom theme and apply your changes into menu.vm. Otherwise if you've meant the breadcrumb create a hook and put your modifications there.

HTH Oli
pawan chauhan
RE: Images/Icons in Navigation Bar
2012/11/15 2:27
答え

pawan chauhan

ランク: Junior Member

投稿: 75

参加年月日: 2012/10/08

最近の投稿

Hi Oliver,
Thanks for the quick reply.
Yes i have created a customized theme according to the requirement.
Now when i add a new page, a text appears on the navigation bar(for example "welcome"), clicking which i move to that page.
I want to replace that text with an image.
Kindly help.

Regards,
Pawan Chauhan.
Oliver Bayer
RE: Images/Icons in Navigation Bar
2012/11/15 8:38
答え

Oliver Bayer

ランク: Liferay Master

投稿: 889

参加年月日: 2009/02/18

最近の投稿

Hi Pawan,

no problem emoticon.

Ok, creating a new theme is the right way to do it. Now you have to copy the original "navigation.vm" (in my first post I've written menu.vm which is wrong, sorry for the mislead) to your "theme-folder \ _diffs \ templates" folder. There you will find the following at line 23:
1<a href="$nav_child.getURL()" $nav_child.getTarget()>$nav_child.getName()</a>

Replace it with sth like that:
1<a href="$nav_child.getURL()" $nav_child.getTarget()><img src="/path-to-your-image/image.jpg" /></a>

Greets Oli
pawan chauhan
RE: Images/Icons in Navigation Bar
2012/11/15 21:43
答え

pawan chauhan

ランク: Junior Member

投稿: 75

参加年月日: 2012/10/08

最近の投稿

Hi Oliver,

Thanks again for the reply.
But i am afraid that what i want to do is a little more complex, I dont want all the links in navigation bar as images. some of them will be text (like "welcome" or "wiki") and few will be images.
Is that possible, Please Advise.

Regards,
Pawan Chauhan
Oliver Bayer
RE: Images/Icons in Navigation Bar
2012/11/16 1:07
答え

Oliver Bayer

ランク: Liferay Master

投稿: 889

参加年月日: 2009/02/18

最近の投稿

Hi Pawan,

for this requirement I would use custom attributes. Define a custom attribute for the type "page" e.g. as text field. Into this text field you can save the image-url for each page individually. Now you have to modifiy the navigation.vm to check if a custom attribute/ image path has been set for the page and use the url as img src value. Otherwise print the page title.

HTH Oli
pawan chauhan
RE: Images/Icons in Navigation Bar
2012/11/16 6:02
答え

pawan chauhan

ランク: Junior Member

投稿: 75

参加年月日: 2012/10/08

最近の投稿

Hi oliver,
Thanks again for the reply.
But i can't actually follow that post. I am a little new to Liferay, can you please be a little more explicit with the reply.
where do i define the custom attribute and how do i put that condition in navigation.vm.
Please explain in detail.
Thanks in advance.

Regards,
Pawan Chauhan.
Oliver Bayer
RE: Images/Icons in Navigation Bar
2012/11/16 12:48
答え

Oliver Bayer

ランク: Liferay Master

投稿: 889

参加年月日: 2009/02/18

最近の投稿

Hi,

ok, let me give it a try but I'm not at work atm so there can be errors in the syntax of the following code nippets emoticon. But at least you should get a good starting point where and how to implement your requirements.

1. Define the custom attribute:
  • Login, then navigate to the control panel, select "custom attributes" from the left side menu under the portal section (if I remember right).
  • Create a new custom attribute for the type "page" as text field (secret/ non indexed) named e.g. "layoutImagePath"

2. Use the custom attribute:
Go to the page management and add an image path for "page A" and leave it blank for "page B"

3. Apply the logic into the navigation.vm:
 1change
 2<a href="$nav_child.getURL()" $nav_child.getTarget()>$nav_child.getName()</a>
 3
 4to sth like that:
 5<a href="$nav_child.getURL()" $nav_child.getTarget()>
 6   #set ($imagePath = $nav_child.getExpandoBridge().getAttribute("layoutImagePath"))
 7   #if ($!imagePath)
 8      <img src="$imagePath" />
 9   #else
10      $nav_child.getName()
11   #end
12</a>

If $nav_child is the current page (in database it's named layout_) then this code should work. Otherwise happy debugging emoticon.

Oli
Desmond Li
RE: Images/Icons in Navigation Bar
2012/11/18 0:09
答え

Desmond Li

ランク: New Member

投稿: 2

参加年月日: 2012/09/22

最近の投稿

Oliver Bayer:
Hi,

ok, let me give it a try but I'm not at work atm so there can be errors in the syntax of the following code nippets emoticon. But at least you should get a good starting point where and how to implement your requirements.

1. Define the custom attribute:
  • Login, then navigate to the control panel, select "custom attributes" from the left side menu under the portal section (if I remember right).
  • Create a new custom attribute for the type "page" as text field (secret/ non indexed) named e.g. "layoutImagePath"

2. Use the custom attribute:
Go to the page management and add an image path for "page A" and leave it blank for "page B"

3. Apply the logic into the navigation.vm:
 1change
 2<a href="$nav_child.getURL()" $nav_child.getTarget()>$nav_child.getName()</a>
 3
 4to sth like that:
 5<a href="$nav_child.getURL()" $nav_child.getTarget()>
 6   #set ($imagePath = $nav_child.getExpandoBridge().getAttribute("layoutImagePath"))
 7   #if ($!imagePath)
 8      <img src="$imagePath" />
 9   #else
10      $nav_child.getName()
11   #end
12</a>

If $nav_child is the current page (in database it's named layout_) then this code should work. Otherwise happy debugging emoticon.

Oli



Where can I find the definition of "$nav_child" ?
Oliver Bayer
RE: Images/Icons in Navigation Bar
2012/11/19 1:38
答え

Oliver Bayer

ランク: Liferay Master

投稿: 889

参加年月日: 2009/02/18

最近の投稿

You can find it in the init.vm of the unstyled theme. There you'll see that the main object is $navItems which is a list of NavItem objects (portal-service: com.liferay.portal.theme.NavItem).

I think you should slightly modify my code snippet:
1#set ($imagePath = $nav_child.[b]getLayout()[/b].getExpandoBridge().getAttribute("layoutImagePath"))

So give it a try and let me know if it works.

Oli