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 / TheTemplate
Created December 11, 2013 18:36
dotcms template code to inspect the content that is on the page and and inject something into the context for other content to use it
#set($THEFLICKR = "")
<div> <h2>What's I got?</h2>
<ul>
#foreach($key in $context.getKeys())
#if($key.startsWith("contentletList"))
#set($cid = $key.replaceAll("contentList", ""))
<li>Container id = $cid - Contents:
<ul>
#foreach($conid in $context.get($key))
<li>$conid
@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 / Test.java
Created June 20, 2014 15:07
Deleting content and related file field in dotCMS
package com.aquent;
import java.util.List;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.UserAPI;
import com.dotmarketing.db.HibernateUtil;
import com.dotmarketing.portlets.contentlet.business.ContentletAPI;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.util.Logger;
@cfalzone
cfalzone / ThreadDump.log
Created January 28, 2014 15:00
Thread Dump
2014-01-28 09:41:25
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode):
"elasticsearch[dotCMS_1][search][T#160]" daemon prio=10 tid=0x00007f411429a000 nid=0xf00 waiting on condition [0x00007f40e85ed000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006c1bc1910> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
@cfalzone
cfalzone / running_queries.sql
Created January 28, 2014 14:54
Running queries on stag - 1/28/2014
-[ RECORD 1 ]----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------