Skip to content

Instantly share code, notes, and snippets.

View sjelfull's full-sized avatar

Fred Carlsen sjelfull

View GitHub Profile
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Convert the existing data to what it would look like in POST
$matrixData = array();
foreach ($entry->matrixField as $block)
{
{% 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 %}

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

<?php if(!defined('EXT')) exit("Invalid file request");
/**
* Post Model Class
*
* @package ci_model_example
* @author Patrick Pohler ppohler@anecka.com
* @copyright Copyright (c) 2014, Patrick Pohler
* @link http://www.anecka.com/rets_press
* @license MIT
<?php if(!defined('EXT')) exit("Invalid file request");
/**
* Base Model Class
*
* @package ci_example
* @author Patrick Pohler ppohler@anecka.com
* @copyright Copyright (c) 2014, Patrick Pohler
* @link http://www.anecka.com/rets_press
* @license MIT
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Convert the existing data to what it would look like in POST
$matrixData = array();
foreach ($entry->matrixField as $block)
{
@sjelfull
sjelfull / index.sql
Last active August 29, 2015 14:06 — forked from litzinger/index.sql
ALTER TABLE exp_channel_titles ADD INDEX sdi(sticky, entry_date, entry_id)
@sjelfull
sjelfull / default.vcl
Last active August 29, 2015 14:06 — forked from timkelty/default.vcl
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
# Switch to 8080 when we go live.
backend default {
.host = "127.0.0.1";
# Varnish 4.0 file for our Craft CMS projects
# Based on https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl
#
# This is still work in progress, comments appreciated.
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
@sjelfull
sjelfull / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console