Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@boboldehampsink
Created June 18, 2015 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boboldehampsink/6bb9e5296977a99c39b1 to your computer and use it in GitHub Desktop.
Save boboldehampsink/6bb9e5296977a99c39b1 to your computer and use it in GitHub Desktop.
Matrix Collapse Plugin, put this in a folder called "matrixcollapse" in craft/plugins/
<?php
namespace Craft;
/**
* Matrix Collapse Plugin.
*/
class MatrixCollapsePlugin extends BasePlugin
{
/**
* Get plugin name.
*
* @return string
*/
public function getName()
{
return Craft::t('Matrix Collapse');
}
/**
* Get plugin version.
*
* @return string
*/
public function getVersion()
{
return '1.0.0';
}
/**
* Get plugin developer.
*
* @return string
*/
public function getDeveloper()
{
return 'Bob Olde Hampsink';
}
/**
* Get plugin developer url.
*
* @return string
*/
public function getDeveloperUrl()
{
return 'http://github.com/boboldehampsink';
}
/**
* Include JS to collapse Matrix Blocks
*/
public function init()
{
if(craft()->request->isCpRequest()) {
craft()->templates->includeJs("$('.matrixblock').each(function(){$(this).addClass('collapsed');Craft.MatrixInput.rememberCollapsedBlockId($(this).data('id'));});");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment