Skip to content

Instantly share code, notes, and snippets.

View makbeta's full-sized avatar

makbeta makbeta

View GitHub Profile
@makbeta
makbeta / isMobile.html
Created October 14, 2013 22:09
Setting isMobile session variable for Luminate Online
<!-- Copyright 2010 Convio, Inc. -->
<!--
Conditional for detecting mobile devices
[[?xx::x[[S80:isMobile]]x::
isMobile is not yet set
[[?xx::x[[S80:UserAgentLowerCase]]x::
UserAgentLowerCase is not yet set
Convert User-Agent from HTTP request header to lower case
[[U0:UserAgentLowerCase=[[E130:"[[S50:User-Agent]]" "A" "a" replaceall "B" "b" replaceall "C" "c" replaceall "D" "d" replaceall "E" "e" replaceall "F" "f" replaceall "G" "g" replaceall "H" "h" replaceall "I" "i" replaceall "J" "j" replaceall "K" "k" replaceall "L" "l" replaceall "M" "m" replaceall "N" "n" replaceall "O" "o" replaceall "P" "p" replaceall "Q" "q" replaceall "R" "r" replaceall "S" "s" replaceall "T" "t" replaceall "U" "u" replaceall "V" "v" replaceall "W" "w" replaceall "X" "x" replaceall "Y" "y" replaceall "Z" "z" replaceall]]]]
@makbeta
makbeta / d7-node-fields-variables.php
Created September 26, 2013 16:25
Drupal7: Make node fields variables for global access
<?php
//this goes into template.php function
function theme_preprocess_page(&$variables, $hook) {
if(isset($variables['node'])) {
$node = node_load($variables['node']->nid);
if($node->type == 'homepage') {
$field_name1 = 'field_left';
$field_name2 = 'field_middle';
$field_name3 = 'field_right';
@makbeta
makbeta / force-layout-settings.php
Created September 16, 2013 00:05 — forked from studiopress/force-layout-settings.php
Wordpress: Genesis layout updates
<?php
//* Do NOT include the opening php tag
//* Force content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
//* Force sidebar-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );
//* Force content-sidebar-sidebar layout setting
@makbeta
makbeta / wordpress-genesis-page-layout.php
Created September 15, 2013 23:55
Wordpress: Genesis set page to full (or any other) width layout
<?php
/*set the Genesis layout to full width or any other width
options as follows:
content-sidebar,
sidebar-content,
content-sidebar-sidebar,
sidebar-sidebar-content,
sidebar-content-sidebar,
full-width-content
*/
@makbeta
makbeta / clo-no-caching.html
Created August 27, 2013 23:25
Luminate Online: Add parameter to js or css files to prevent caching
nocache=[[S55:1000,99999]]
@makbeta
makbeta / jq-show-hide-placeholder.js
Last active December 21, 2015 09:29
jQuery: show/hide placeholder text in form inputs on hover
$.fn.showHidePlaceholder = function(defaultValue) {
$(this).each(function() {
var $element = $(this);
if($element[0].tagName.toLowerCase() == 'select') {
$selectedOption = $element.children('option:selected');
if($selectedOption.text() == defaultValue || $selectedOption.val() == defaultValue) {
$element.addClass('placeholder');
}
@makbeta
makbeta / drupal-contact-embed-template.php
Created August 20, 2013 17:44
Drupal7: embed site contact form in the node template
<?php
//render site contact form on the contact-us page [put this code in your node.tpl.php where you want the form to appear]
if($node->nid == 4) {
require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';
$contact_form = drupal_get_form('contact_site_form');
print drupal_render($contact_form);
}
?>
@makbeta
makbeta / resize-iframe.js
Created August 1, 2013 20:35
JS: Resize javascript to the width of the container if it's smaller than iframe
function resizeIframes($iframes) {
$iframes.each(function() {
var $iframe = $(this);
var height = $iframe.height();
var width = $iframe.width();
var parentWidth = $iframe.parent().width();
var newHeight = Math.ceil(parentWidth*(height/width));
if(parentWidth <= width) {
$iframe.attr('width', parentWidth);
$iframe.width(parentWidth);
@makbeta
makbeta / parent-url.js
Created July 30, 2013 18:34
JS: URL of the parent from iframe
var url = (window.location != window.parent.location) ? document.referrer: document.location;
@makbeta
makbeta / redirect-based-on-parameter.js
Created July 18, 2013 05:25
Redirect the page based on URL parameters
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
if((getParameterByName('FR_ID') == '1070' || getParameterByName('fr_id') == '1070') && (!getParameterByName('pw_id')) ) {
window.location = window.location + '&pw_id=1741';
}