This file contains hidden or 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
public function modifyEntryTableAttributes( &$attributes, $source ) { | |
// Note: the number "3" is the relevant section's ID | |
if ($source == 'section:3') | |
{ | |
// Add a dummy field key – this could be called anything but avoid conflicts | |
$attributes['myEntryAuthorCategory'] = Craft::t('Author category'); | |
} | |
} | |
public function getEntryTableAttributeHtml(EntryModel $entry, $attribute) |
This file contains hidden or 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
{# Get the related nav item for the current entry #} | |
{% set navItem = craft.entries.section('navigation').relatedTo(entry).first() %} | |
{% if navItem %} | |
{# Get the top level page for the nav item #} | |
{% set topPage = navItem.getAncestors().level(1).first()|default(navItem) %} | |
{# Build a "pages" array w/ the top page and its descendents (child entries) #} | |
{% set pages = craft.entries.id([topPage.id]|merge(topPage.getDescendants().ids()|default([]))) %} | |
<nav> | |
<ul> | |
{% nav page in pages %} |
This file contains hidden or 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 | |
// [myCustomShortcode type="tip"]Dette er et godt tips[/myCustomShortcode] | |
function clientName_myCustomShortcode_func( $atts, $content = null ) { | |
$args = shortcode_atts( array( | |
'type' => 'tip', | |
), $atts ); | |
if ( ! $content ) { | |
return ''; | |
} |
This file contains hidden or 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
{# Fetch the category "myCategory" (and any child categories as well) #} | |
{% set categories = craft.categories.slug( 'myCategory' ) %} | |
{# Search for entries in section "test", that has the category "myCategory" (or any of its child categories) selected in the field "category" of the Matrix block "testMatrix" #} | |
{% set entries = craft.entries.section( 'test' ).relatedTo({ | |
targetElement: categories, | |
field: 'testMatrix.category' | |
}) %} | |
{# Output the entries #} |
This file contains hidden or 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
{ | |
"require": { | |
"composer/installers": "~1", | |
"jarednova/timber": "dev-master" | |
}, | |
"repositories": [ | |
{ | |
"type" : "package", | |
"package" : { | |
"name" : "jarednova/php-router", |
This file contains hidden or 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 | |
class MyPost extends TimberPost { | |
public function __construct( $post_id = null, $post_type = 'post' ) { | |
if ( is_string( $post_id ) ) { | |
// If $post_id is a string, we'll consider it a slug and try to get the ID | |
$args = array( |
NewerOlder