How to create breadcrumb in Velocity Template

4.4k views Asked by At

I'm trying to create a custom Velocity Template for a banner which includes a breadcrumb but have no idea how to go about it. I've noticed the line which says #breadcrumb() in portal_normal.vm looks like a Velocity macro, but I cannot find the macro to try and replicate this.

Any ideas?

2

There are 2 answers

0
Dusan On

You can find it in source code of portal, in file portal-impl\src\VM_liferay.vm.

It is defined as:

#macro (breadcrumbs $control_panel)
    #set ($breadcrumb_tag = $theme.getBreadcrumbTag())

    #if ($control_panel == "control_panel")
        $breadcrumb_tag.setShowGuestGroup(false)
        $breadcrumb_tag.setShowParentGroups(false)
    #end

    $breadcrumb_tag.runTag()
#end
0
Aparaatti On

The highlevel layout of the whole portal is in the portal_normal.vm, which atleast in 6.1. calssic theme consists of div tags for heading, content and footer. The banner is between the

<div id="heading">
 ...
</div>

block. So you probably only need to move the

<nav class="site-breadcrumbs" id="breadcrumbs">
    #breadcrumbs()
</nav>

to the right place inside that block.

You could also divide the velocity macros to multiple files with

#parse("$full_template_path/name_of_custom_velocity_file.vm")

commands, which I just did :) Eg. I made own file for header, content and footer.