Skip to content

Instantly share code, notes, and snippets.

View imagehat's full-sized avatar

Mike Kroll imagehat

  • Surprise Highway
  • Madison, WI
View GitHub Profile
//Split into two columns
var marker = Math.round($('#sitemap > li').length / 2);
$('#sitemap > li').each(function(i) {
if (i >= marker) $(this).addClass('colsplit');
});
$('#sitemap li.colsplit').insertAfter('#sitemap').wrapAll('<ul class="columns-2"></ul>').removeClass('colsplit');
$('#sitemap').addClass("columns-2");
// Split into two columns accounting for nested list items
var midway = Math.round($('#sitemap li').length / 2);
var $node = $('#sitemap li:eq('+midway+')');
var $parent = $node.parent().parent();
var marker = ( $parent.is('li') ) ? $('#sitemap > li').index($parent) : $('#sitemap > li').index($node);
$('#sitemap > li').each(function(i) {
if (i > marker) $(this).addClass('colsplit');
$new = substr_replace($string, $insert, $position, 0);
{exp:weblog:entries weblog="${1:weblog1}" ${2:parameters} disable="categories|category_fields|member_data|pagination|trackbacks"}
$0
{/exp:weblog:entries}
// Config overrides - http://expressionengine.com/wiki/EE_2_Config_Overrides/
$config['index_page'] = '';
$config['site_url'] = "http://${_SERVER['HTTP_HOST']}/";
$config['cp_url'] = $config['site_url'].SYSDIR."/index.php";
$config['captcha_url'] = "http://${_SERVER['HTTP_HOST']}/images/captchas/";
$config['emoticon_path'] = "http://${_SERVER['HTTP_HOST']}/images/smileys/";
$config['photo_url'] = "http://${_SERVER['HTTP_HOST']}/images/member_photos/";
$config['sig_img_url'] = "http://${_SERVER['HTTP_HOST']}/images/signature_attachments/";
$config['theme_folder_url'] = "http://${_SERVER['HTTP_HOST']}/themes/";
$config['theme_folder_path'] = "${_SERVER['DOCUMENT_ROOT']}/themes/";
------------
JS
------------
// After all images load, not dom-ready
$(window).load(function(){
if(!$("#slideshow").length) return;
// Images to add to slideshow
@imagehat
imagehat / gist:1418214
Created December 1, 2011 17:02
EE snippet for appending read more link inside last closing html tag
{exp:low_replace
regex="yes"
find="(<\/(.*)>)(\s+)$"
replace="SPACE<a class='more' href='{title_permalink=bulletin}'>[read more]</a>$1"
}
{blog_excerpt}
{/exp:low_replace}
@imagehat
imagehat / wget.sh
Created September 11, 2012 14:54 — forked from manifestuk/wget.sh
Gist for retrieving a full website using wget, because I always forget the options.
#
# Explanation:
# -E Adjust extension.
# -k Convert links.
# -N Enable timestamping.
# -np No parent.
# -p Page requisites.
# -r Recursive.
# -w1 The time to wait between requests.
# --random-wait Wait times 0.5 to 1.5.
@imagehat
imagehat / gist:5213767
Created March 21, 2013 15:09
EE forum module hack to add forum_id variable to exp:forum:topic_titles for linking to individual topics
In mod.forum_core.php around line 11003 find:
// Single Variables
foreach ($this->EE->TMPL->var_single as $key => $val)
{
// parse {post_total}
if ($key == 'post_total')
{
$tagdata = $this->EE->TMPL->swap_var_single($key, $row['thread_total'], $tagdata);
}
@imagehat
imagehat / gist:5467788
Last active December 16, 2015 17:08
Open external links and PDFs in a new window
// Open external links and PDFs in a new window
$("a[href^='http'], a[href$='.pdf']").each(function() {
if(this.href.indexOf(location.hostname.replace(/www./gi, "")) == -1 || this.href.lastIndexOf('.pdf') !== -1) {
// Ensure subdomains are not counted as external
if(this.href.indexOf('mywebsite.com') == -1) {
$(this).click(function() {
window.open(this.href, "_blank");
return false;
});
}