Skip to content

Instantly share code, notes, and snippets.

View cfalzone's full-sized avatar

Christopher Falzone cfalzone

  • Aquent
  • Erie County, PA
View GitHub Profile
@cfalzone
cfalzone / page-asset-select.vtl
Created September 13, 2018 13:48
Page Asset Custom Field
#if(!$UtilMethods.isSet($customPageAssetFieldVar))
#set($customPageAssetFieldVar = 'pageAsset')
#end
#if(!$UtilMethods.isSet($pageUrlDummyField))
#set($pageUrlDummyField = 'pageUrl')
#end
#set($pageAssetValue = $context.get($customPageAssetFieldVar))
#if(!$UtilMethods.isSet($hostId))
#set($hostId = $host.identifier)
#end
@cfalzone
cfalzone / generic-relation-select.vtl
Last active September 10, 2018 15:10
dotCMS Single Select Custom Field using Dojo Filtering Select or jQuery
#if(!$UtilMethods.isSet($fieldVar))
#set($fieldVar = 'market')
#end
#if(!$UtilMethods.isSet($stName))
#set($stName = 'Markets')
#end
#if(!$UtilMethods.isSet($sortOrder))
#set($sortOrder = "${stName}.title")
@cfalzone
cfalzone / The-Custom-Field-Code.vtl
Last active September 7, 2018 19:07
This is how we do dotCMS Custom Content Driven Multi-Selects
## This is the code in the custom field
#set($fieldVar = 'market') ## This field's Velocity Var Name
#set($stName = 'Markets') ## The Structure Name to Pull From
#set($sortOrder = "${stName}.title") ## The order to sort the results in
#set($conditions = "") ## Sometimes it is neccessary to pass more conditions to the query
#set($limit = 0) ## The Query Limit
#set($valueField = "marketId") ## The Name of the field in the structure to get the value from
#set($lblField = "name") ## The name of the field in the structure to get the label from
@cfalzone
cfalzone / AquentActivator.java
Created January 5, 2017 13:36
Rest API for dotCMS
package com.aquent.osgi;
import com.aquent.AquentResource;
import com.dotcms.repackage.org.apache.felix.http.api.ExtHttpService;
import com.dotcms.repackage.org.osgi.framework.BundleContext;
import com.dotcms.repackage.org.osgi.framework.ServiceReference;
import com.dotcms.repackage.org.osgi.util.tracker.ServiceTracker;
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.Condition;
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.NormalRule;
@cfalzone
cfalzone / Pushing.java
Created October 11, 2016 11:33
Just some methods to push content in dotCMS
public final class Pushing {
public static final Pushing INSTANCE = new Pushing();
private User sysUser = null;
private EnvironmentAPI envAPI = APILocator.getEnvironmentAPI();
private BundleAPI bundleAPI = APILocator.getBundleAPI();
private PublisherAPI pubAPI = PublisherAPI.getInstance();
private UserAPI userAPI = APILocator.getUserAPI();
private Pushing() { }
@cfalzone
cfalzone / CreateStructure.java
Created April 19, 2016 15:46
Old 2.0 Code to create a structure in dotCMS
private void createStructure(String stVarName, Host stHost, JSONObject json) throws Exception {
Structure st = new Structure();
st.setDefaultStructure(false);
st.setFixed(false);
st.setStructureType(Structure.STRUCTURE_TYPE_CONTENT);
st.setName(json.getString("name"));
st.setVelocityVarName(stVarName);
st.setHost(stHost.getIdentifier());
try {
@cfalzone
cfalzone / JobPostingService.java
Last active November 30, 2015 14:31
A soap client example for dotCMS. PostedJob and LocalizePostingDetails are just POJOs that represent the objects being returned by the soap client.
package com.aquent.jobs;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@cfalzone
cfalzone / jvmCrashTest.jsp
Created November 4, 2015 18:30
dotCMS JVM Crash Test Dummy - Tests to see if your JVM is susceptible to an SSL crash. Typically if it is you will crash the server after 4075 length. Otherwise if it gets to > 5000 you are most likely safe.
<%@page import="com.dotmarketing.util.Logger"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JVM Crash Test Dummy</title>
</head>
<body>
Contentlet Dependencies:
>> Add the Contentlet's Host
>> Add the Contentlet's Relationships
>> Foreach Related Contentlet + This Contentlet
>> Add the Host
>> Foreach Contentlet referenced in an Image or File Field of this Contentlet + this Contentlet
>> Add the Host
>> Add the Contentlet
>> Add the Folder
>> Add the Language
@cfalzone
cfalzone / flatnav.vtl
Created October 30, 2015 18:56
dotCMS Flat Navigation Example (not tested)
## Define a macro to handle the children
#macro(navFlatChildren $nav_children, $level)
#foreach($nav_item in $nav_list)
#if(!$nav_item.folder && $UtilMethods.isSet($nav_item.href))
## so we are not a folder and we have a url so show a link
<li><a href="${nav_item.href}">$nav_item.title</a></li>
#else
#if($nav_item.folder
&& $nav_item.children
&& $nav_item.children.size() > 0