Here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft CMS.
This file contains 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
(function($){ | |
$(function(){ | |
var $form = $('#search'), // Search form | |
$target = $('#results'), // Results container | |
rp = 'search/ajax-results'; // Template for results only | |
// Function to execute on success | |
var success = function(data, status, xhr) { | |
$target.html(data); | |
}; |
This file contains 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
// ---------------------------------------------- | |
// Detect screen orientation | |
// ---------------------------------------------- | |
var deviceOrientation = ''; // Declare globally to use throughout | |
function detectOrientation () { | |
var windowWidth = $(window).height(); | |
var windowHeight = $(window).width(); | |
if (windowWidth > windowHeight) { | |
deviceOrientation = 'landscape'; | |
} else { |
This file contains 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
// Declare globally to use throughout | |
var deviceOrientation = ''; | |
// ---------------------------------------------------- | |
// Detect screen orientation | |
// ---------------------------------------------------- | |
function detectOrientation() { | |
var height = $(window).height(); | |
var width = $(window).width(); | |
if(width > height) { |
This file contains 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
# gzip compression -- make it faster! | |
SetOutputFilter DEFLATE | |
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html | |
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip | |
Header append Vary User-Agent env=!dont-vary |
This file contains 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
<?php | |
namespace Craft; | |
// This file could be placed into your public_html folder and visited to import a cheese product. | |
$craft = require '../craft/app/bootstrap.php'; | |
$craft->plugins->loadPlugins(); | |
$newProduct = new Commerce_ProductModel(); |
This file contains 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
for app in $(heroku apps); do heroku apps:destroy --app $app --confirm $app; done |
This file contains 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
var hqLocation = new google.maps.LatLng(-35.107231, 147.369983); | |
var mapOptions = { | |
zoom: 17, | |
minZoom: 17, | |
maxZoom: 17, | |
center: hqLocation, | |
scrollwheel: false, | |
disableDefaultUI: true, | |
keyboardShortcuts: false, |
This file contains 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
<!DOCTYPE html> | |
<head> | |
{# Base #} | |
{% includeCssFile 'layouts/base/css/base.css' %} | |
{% includeJsFile 'layouts/base/js/base.js' %} | |
{# Header #} | |
{% includeCssFile 'modules/header/css/header.css' %} | |
{% includeJsFile 'modules/header/js/header.js' %} |
This file contains 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
var pageURL = window.location.href; | |
var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); | |
console.log(lastURLSegment); |
OlderNewer