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
body, form { | |
margin: 0; | |
padding: 0; | |
} | |
a { | |
color: #039; | |
} | |
a:hover { |
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
{% spaceless %} | |
{% set srcsets = [] %} | |
{% for image in entry.images %} | |
{% set imgSize = max(image.width, image.height) %} | |
{% set transformedImages = craft.imager.transformImage(image, [ | |
{ width: imgSize >= 1200 ? 1200 : imgSize, jpegQuality: 90 }, | |
{ width: imgSize >= 1000 ? 1000 : imgSize, jpegQuality: 90 }, | |
{ width: 600 }, |
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
photo = $('#photo') | |
offset = photo.offset() | |
photoViewportOffsetTop = offset.top - $(document).scrollTop() | |
photoViewportOffsetLeft = offset.left - $(document).scrollLeft() |
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 |
OlderNewer