Here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft CMS.
I hereby claim:
- I am brandonkelly on github.
- I am brandonkelly (https://keybase.io/brandonkelly) on keybase.
- I have a public key ASBSTBHBxc0E6qGHlzL0iNPFzO-j9rWbFHyjoGuYIxhbygo
To claim this, I am signing this object:
This file contains 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 | |
namespace foo\bar; | |
use yii\log\Target; | |
/** | |
* Define a LogTarget class that only collects the log messages, but never flushes them out anywhere | |
*/ | |
class LogTarget extends Target | |
{ |
This file contains 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
// ------------------------------------------- | |
// Include the Sheet resources in PHP | |
// ------------------------------------------- | |
if (! class_exists('Assets_helper')) | |
{ | |
require PATH_THIRD.'assets/helper.php'; | |
} | |
$assets_helper = new Assets_helper; |
This file contains 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 | |
/** | |
* Get Upload Preferences (Cross-compatible between ExpressionEngine 2.0 and 2.4) | |
* @param int $group_id Member group ID specified when returning allowed upload directories only for that member group | |
* @param int $id Specific ID of upload destination to return | |
* @return array Result array of DB object, possibly merged with custom file upload settings (if on EE 2.4+) | |
*/ | |
function get_upload_preferences($group_id = NULL, $id = NULL) | |
{ |
This file contains 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 | |
// -- modules/Module.php -- | |
namespace modules; | |
use Craft; | |
use craft\base\Element; | |
use craft\elements\Entry; | |
use craft\events\RegisterPreviewTargetsEvent; |
This file contains 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 | |
// 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) | |
{ |
This file contains 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
After clicking Changes > Install Terminal Utility…, add this to ~/.gitconfig: | |
[diff] | |
tool = changes-app | |
[difftool "changes-app"] | |
cmd = /usr/bin/chdiff $LOCAL $REMOTE | |
[difftool] |
This file contains 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 if (! defined('BASEPATH')) exit('No direct script access allowed'); | |
require_once PATH_THIRD.'matrix/config.php'; | |
/** | |
* Wygwam Custom Toolbar Button | |
* | |
* This is a sample extension that would add a plugin to Wygwam’s extraPlugins setting, |
NewerOlder