Skip to content

Instantly share code, notes, and snippets.

{# for regular fields #}
{% if entry.fieldHandle %}
{{ entry.fieldHandle}}
{% else %}
{{ global.fieldHandle}}
{% endif %}
{# for array fields (entries, assets, etc) #}
@keithmancuso
keithmancuso / gist:226d58d0fb572face586
Created September 30, 2014 01:54
SalesforceOAuthProviderSource
<?php
/**
* Craft OAuth by Dukt
*
* @package Craft OAuth
* @author Benjamin David
* @copyright Copyright (c) 2014, Dukt
* @license https://dukt.net/craft/oauth/docs/license
* @link https://dukt.net/craft/oauth/
@keithmancuso
keithmancuso / gist:24ce1eefa8269c01353a
Created September 30, 2014 20:13
Salesforce Contact Event
public function init()
{
craft()->users->onActivateUser = function(Event $event) {
$user = $event->params['user'];
// check salesforce for contact with that email address
// if exists, get contact ID and save it on user
// if doesnt exist create contact and account (using organization name) and save contactID on user
<form method="post" action="" id="login-form" accept-charset="UTF-8">
<input type="hidden" name="action" value="users/login">
<input type="hidden" name="redirect" value="{{redirect}}">
<div class="form-group">
<label for="email">Email</label>
<input id="email" type="text" name="loginName" class="form-control">
</div>
@keithmancuso
keithmancuso / gist:dd2c539dc85b4bc9736d
Last active August 29, 2015 14:07
Jquery initialize directive
app.directive ('modal', function() {
return {
replace: false,
link:function (scope, element, attrs) {
element.fitVids();
}
}
})
<?php
namespace Craft;
class SalesforceController extends BaseController
{
private $scopes = array();
private $params = array();
public function actionGetStudents() {
return 'test this stuff out';
@keithmancuso
keithmancuso / The other way
Last active August 29, 2015 14:17
City switcher
{% set segments = craft.request.getSegments() %}
{% set newUrl = segments[2:segments|length] %}
{% set newUrl = city.slug ~ newUrl %}
public PageReference checkIfNotNominee() {
User theUser = GlobalVariables.getCurrentUser();
Coontact theContact = GlobalVariables.getCurrentContact(theUser);
if (theContact.RecordTypeId != RecordTypeConstant.nomineeContactRecordTypeId) {
PageReference page = System.Page.PosseCommunity;
page.setRedirect(true);
return page;
} else {
@keithmancuso
keithmancuso / familiarASCII.txt
Last active January 31, 2016 16:31
Familiar ASCII Art
<!-- Site by Familiar
//////////////////////
//////////////////////
//////////////////////
///////
///////
///////
///////
///////
///////////////////////
@keithmancuso
keithmancuso / redirect.conf
Created January 31, 2016 16:37
NGINX redirect
server {
listen 80;
server_name familiar.studio www.familiar-studio.com www.familiar.studio familiarstudio.com www.familiarstudio.com familiar.io familiar.is;
return 301 http://familiar-studio.com$request_uri;
}