Skip to content

Instantly share code, notes, and snippets.

@brandonkelly
brandonkelly / gist:8771071
Created February 2, 2014 16:37
Grabbing “parent” Matrix rows, where the Matrix field has a Playa cell that is relating to a given entry.
{exp:channel:entries ... }
{exp:playa:parents field="matrix_field_name" col="playa_col_name" var_prefix="parent"}
{parent:matrix_field search:matrix_col_name="[{entry_id}]" var_prefix="row"}
{row:some_col_name}
{!-- we can even loop through all of those related entries
(which will include the top-level entry) if we want... --}
@brandonkelly
brandonkelly / HttpRequestVariable.php.diff
Created February 17, 2014 23:35
Add a craft.request.getPageNum() function to Craft
diff --git Source/craft/app/variables/HttpRequestVariable.php Source/craft/app/variables/HttpRequestVariable.php
index fad31b7edab84f5c428e3ce2c3b3ec6e8d92e7ef..430e1adcdf801cccabaf67c89001465c8835fba7 100644
--- Source/craft/app/variables/HttpRequestVariable.php
+++ Source/craft/app/variables/HttpRequestVariable.php
@@ -201,4 +201,14 @@ class HttpRequestVariable
{
return craft()->request->isMobileBrowser($detectTablets);
}
+
+ /**
{% macro entryLink(entry, selEntry) %}
{% if entry.type == 'link' %}
<a href="{{ url(entry.linkUrl) }}">{{ entry.title }}<span class="external"></span></a>
{% elseif entry.type == 'headingOnly' %}
{% set nextEntry = entry.getNext() %}
{% if nextEntry %}
<a href="{{ nextEntry.url }}">{{ entry.title }}</a>
{% else %}
{{ entry.title }}
{% endif %}
@brandonkelly
brandonkelly / FieldsVariable.php
Created March 10, 2014 18:55
craft.fields.getFieldByHandle()
<?php
// ...
public function getFieldByHandle($handle)
{
return craft()->fields->getFieldByHandle($handle);
}
<?php
namespace Craft;
class CompatibilityPlugin extends BasePlugin
{
function getName()
{
return Craft::t('Browser Compatibility');
}
<?php
namespace Craft;
class CompatibilityPlugin extends BasePlugin
{
function getName()
{
return Craft::t('Browser Compatibility');
}
<?php
// __call() test
// ===========================================================================
class MyBaseClass {
function _call($method, $args)
{
echo($args[0]);
return TRUE;
<?php
// Code trimmed out while porting Playa to a FieldFrame extension
// ===========================================================================
/**
* Extension Constructor
*
* @param array $settings
* @since version 1.0.0
*/
// What I did
$myField.resizable({
handles: ['.ui-resizable-handle'], // I already have this as a jQuery object, but passing it threw an error
alsoResize: '#'+myFieldId+' .scrollPane', // No way to specify the containment, so I had to add prepend the field ID. (allowing a jQuery object would fix that as well)
containment: 'parent', // This keeps the width from getting wider
resize: function() {
$(this).width('100%'); // This keeps the width from getting narrower
$('.scrollPane', this).width('100%'); // This keeps the alsoResize elements from changing widths
}
@brandonkelly
brandonkelly / gist:131005
Created June 17, 2009 00:33
TextMate File Pattern that shows .gitignore files
!(/\.(?!htaccess|gitignore)[^/]*|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$