Skip to content

Instantly share code, notes, and snippets.

View ryan-ethode's full-sized avatar

Ryan Simmons ryan-ethode

View GitHub Profile
@ryan-ethode
ryan-ethode / Parent Sibling Folder Navigation
Last active November 11, 2015 17:07
This Velocity grabs the parent folder of the page you are on and creates a menu based on other parent elements.
#set ($navPath = $VTLSERVLET_URI.substring(0, $VTLSERVLET_URI.indexOf('/',1)) + "/")
#set( $list = $navtool.getNav("$navPath"))
<ul>
#foreach($n in $list)
<li>
<a href='${n.href}'>${n.title}</a>
</li>
#end
</ul>
@ryan-ethode
ryan-ethode / print-div.html
Created March 3, 2016 16:58
A print button that only prints the contents of a specific div, rather than a whole page.
<div id="print-contents">
<!-- Your content goes here. -->
</div>
<script>
printDivCSS = new String ('<link href="../css/main.css" rel="stylesheet" type="text/css">')
//The line referencing your CSS will keep your printed div formatting looking correct.
function printDiv(divId) {
window.frames["print_frame"].document.body.innerHTML=printDivCSS + document.getElementById(divId).innerHTML;
window.frames["print_frame"].window.focus();
@ryan-ethode
ryan-ethode / dotcms-rss.dot
Last active March 3, 2016 17:00
This creates a DotCMS RSS feed based on a content structure.
#set ($query="+structureName:Blog +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST), 10, modDate desc")
<xml version="1.0" encoding="UTF-8">
<rss version="2.0">
<channel>
<pubDate>1 Jan 2006 23:23:04 GMT</pubDate>
<title>Company Blog</title>
<description>Tips and Tricks</description>
<link>http://www.website.com/blog/</link>
<copyright>2006-2015 Company Name</copyright>
@ryan-ethode
ryan-ethode / velocity-template-var-export.dot
Created September 29, 2016 14:35
A great little snippet to view all of the variables available to a velocity template
#foreach($key in $context.keys) <pre> $key</pre> #end
@ryan-ethode
ryan-ethode / url-replace.js
Last active November 10, 2016 15:32
URL Replacer: Used on a multi-site host to direct relative URLs from one host to another host.
$("a").each(function() {
if($(this).parents('.info').length) {
var href = $(this).prop('href');
var href = href.replace("https://somewebsite.com/", "https://someotherwebsite.com/");
$(this).prop('href', href);
$(this).attr('target','_blank');
}
});
@ryan-ethode
ryan-ethode / external-sites-new-tab.js
Created January 12, 2017 20:35
Automatically open all external website links in a new tab.
$( document ).ready(function() {
$(".container a").each(function() {
var pageUrl = $(this).attr("href");
if(pageUrl == null) {
var pageUrl = "nothing";
}
if(pageUrl.indexOf("://") > 0 && pageUrl.indexOf("yourdomain.com") < 0) {
$(this).attr("target","_blank");
}
@ryan-ethode
ryan-ethode / default.php
Created February 9, 2018 04:13
Article Category Joomla Module hack to display list in clickable dropdown field rather than in an unordered list.
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_category
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
@ryan-ethode
ryan-ethode / linux-cheat-sheet.md
Last active August 20, 2021 16:37
Linux CLI Commands

Restart Apache (after making Apache config changes or PHP changes)

apachectl restart 
or:
/sbin/service httpd restart

Restart MariaDB (after making any sort of config change)

systemctl restart mariadb
#set($cont = $dotcontent.query("+identifier:942ec5f5-9d49-4f34-a2ca-109201c4a21b +languageId:1620518258288", 1)) ##using French language id here
#set($inode = $cont.get(0).inode)
#set($contInFrench = $dotcontent.find("$!{inode}"))
<p>SEO Description = $contInFrench.seodescription</p>
##$result.uri = "/some/address/index"
#set($segments = $result.uri.split('/'))
#set($segmentOne = $segments[1])
#set($segmentTwo = $segments[2])
$segmentOne = "some"
$segmentTwo = "address"