How to Create a PHP Include in Velocity

Published May 15, 2014 | Categories: Web Development
If you work with Velocity and need to add a PHP include, there is a simple way. As you know the hash tag is the main character before a directive or code comment. So you can’t use it for regular text or inline copy if it’s within the velocity code itself.
The way to get around it is to create a variable. When processing it adds the needed hash tag for the PHP include and can successfully preview the include file in the web browser(s).
Example:
#set($pages = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-page"))
#foreach($page in $pages)
#set ( $hash = '#' )
#set ($path = $page.getChild("path").value)
<!-- #[[#include]]# file="" -->
#end
Recent Posts

Hello from Beaconville: High Ed Conference Wrap-Up
View this Story

Cue the Confetti: Celebrating 2022's Higher Ed Wins So Far
View this Story

Beacon Technologies Opens Second Location in Carolina Beach, NC
View this Story

Why You Need Audience Personas For Your Website Content
View this Story