Created
October 1, 2013 14:50
-
-
Save cfalzone/6779697 to your computer and use it in GitHub Desktop.
Some beta code to show which pages are using which templates in dotCMS. Very slow and using a not-so-great ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@page import="java.util.HashMap"%> | |
<%@page import="com.dotmarketing.portlets.htmlpages.business.HTMLPageAPI"%> | |
<%@page import="com.dotmarketing.portlets.htmlpages.model.HTMLPage"%> | |
<%@page import="com.dotmarketing.portlets.templates.business.TemplateAPI"%> | |
<%@page import="com.dotmarketing.portlets.templates.model.Template"%> | |
<%@page import="com.liferay.portal.model.User"%> | |
<%@page import="com.dotmarketing.business.APILocator"%> | |
<%@page import="com.dotmarketing.beans.Host"%> | |
<%@page import="java.util.List"%> | |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | |
pageEncoding="ISO-8859-1"%> | |
<!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=ISO-8859-1"> | |
<title>Template Page Usage</title> | |
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/cupertino/jquery-ui.css" rel="stylesheet" type="text/css"> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$(".templates").accordion({heightStyle: "content", collapsible:true, active:false}); | |
$(".hosts").accordion({heightStyle: "content", collapsible:true, active:false}); | |
$(".hosts h2").css('padding-left', '20px'); | |
$(".templates h3").css('padding-left', '20px'); | |
$(".page-archived").css('color', 'red'); | |
$(".page-live").css('color', 'green'); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1> Template Page Usage Per Host</h1> | |
<div class="wrapper"> | |
<div class="hosts"> | |
<% | |
TemplateAPI tempAPI = APILocator.getTemplateAPI(); | |
HTMLPageAPI pageAPI = APILocator.getHTMLPageAPI(); | |
User sysUser = APILocator.getUserAPI().getSystemUser(); | |
List<Host> hosts = APILocator.getHostAPI().findAll(sysUser, false); | |
for(Host host : hosts) { | |
List<Template> temps = tempAPI.findTemplatesAssignedTo(host); | |
if(temps.size() > 0 && !host.isArchived()) { | |
%> | |
<h2><%=host.getHostname()%></h2> | |
<div class="host"> | |
<div class="templates"> | |
<% | |
for(Template temp : temps) { | |
List<HTMLPage> pages = pageAPI.findHtmlPages(sysUser, true, new HashMap<String, Object>(), host.getIdentifier(), null, null, temp.getIdentifier(), 0, 10, ""); | |
%> | |
<h3><%=temp.getTitle()%></h3> | |
<div class="template"> | |
<% | |
if(pages.size() > 0) { | |
%> | |
<p> Pages that use this template: </p> | |
<ul class="pages"> | |
<% | |
for(HTMLPage p : pages) { | |
String c = "live"; | |
if(p.isArchived()) c = "archived"; | |
%> | |
<li class="page-<%=c%>"><%=p.getURI()%></li> | |
<% | |
} | |
%> | |
</ul> | |
<% | |
} else { | |
%> | |
<p> No Pages Use this Template </p> | |
<% | |
} | |
%> | |
</div> | |
<% | |
} | |
%> | |
</div> | |
</div> | |
<% | |
} | |
} | |
%> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment