Skip to content

Instantly share code, notes, and snippets.

View mdcpepper's full-sized avatar

Mike Pepper mdcpepper

View GitHub Profile
$query = craft()->elements->buildElementsQuery();
$query->andWhere(DbHelper::parseDateParam("content.field_eventStart", '>='.$startDate, $query->params));
$query->andWhere(DbHelper::parseDateParam("content.field_eventEnd", '<='.$endDate, $query->params));
$results = $query->queryAll();
{% set excludedIds = [] %}
{% set allProducts = craft.entries.section('products') %}
{% for product in allProducts %}
{% if product.productCategories|length %}
{% set excludedIds = excludedIds|merge(['not '~product.id]) %}
{% endif %}
{% endfor %}
{% set products = craft.entries.section('products').id(excludedIds).limit(null) %}
{# news/_entry.twig #}
{% block breadcrumbs %}
{{ macro.breadcrumbs(entry, { parent: craft.entries.id(45).first() }) }}
{% endblock %}
{% macro datesBetween(startDate, endDate, currentDate = null) %}
{% import _self as self %}
{# initialize the currentDate from the startDate #}
{% if currentDate is null %}
{% set currentDate = startDate %}
{% endif %}
{# echo the current date, or the startDate if it's the first run #}
<li>{{ currentDate }}</li>
{% set searchTerm = craft.request.getParam('search') %}
{% set entries = craft.entries.hideFromSearchResults([0]).search(searchTerm).limit(25) %}
{% if searchTerm and entries|length %}
{% paginate entries as page %}
{% for entry in page %}
{% include [ entry.section.handle~"/_excerpt-search",
"pages/_excerpt-search",
"_errors/template-missing-search" ] %}
{% endfor %}
{% set navElements = { 1: 'section', 2: 'article' } %}
{% nav entry in entries %}
{# fetch the HTML element matching the entry level #}
<{{ navElements[entry.level]|default('div') }}>
{{ entry.content }}
{% ifchildren %}
{%- if currentUser.admin
or (
( entry.authorId == currentUser.id and currentUser.can('editEntries:' ~ entry.section.id) )
or ( entry.authorId != currentUser.id and currentUser.can('editPeerEntries:' ~ entry.section.id) )
or (
entry.section.type == 'Single' and
( entry.authorId == currentUser.id and currentUser.can('editEntries:' ~ entry.section.id) )
or ( entry.authorId != currentUser.id and currentUser.can('editPeerEntryDrafts:' ~ entry.section.id) )
)
)
@mdcpepper
mdcpepper / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
<?php
namespace Craft;
class EntryTypeSourcesPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Entry Type Sources');
}