Skip to content

Instantly share code, notes, and snippets.

@davist11
Created April 12, 2012 22:33
Show Gist options
  • Save davist11/2371479 to your computer and use it in GitHub Desktop.
Save davist11/2371479 to your computer and use it in GitHub Desktop.
Viget.com Accessory
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ExpressionEngine - by EllisLab
*
* @package ExpressionEngine
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2003 - 2011, EllisLab, Inc.
* @license http://expressionengine.com/user_guide/license.html
* @link http://expressionengine.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Fix-ee Accessory
*
* @package ExpressionEngine
* @subpackage Addons
* @category Accessory
* @author Trevor Davis
* @link http://trevordavis.net
*/
class Viget_acc {
public $name = 'Viget';
public $id = 'viget';
public $version = '1.0';
public $description = 'Ability to add JS to sections to change stuff.';
public $sections = array();
/**
* Set Sections
*/
public function set_sections()
{
$EE =& get_instance();
$additionalJS = '';
//Change career and blog category checkboxes to radios
if($EE->input->get('C') === 'content_publish' && $EE->input->get('M') === 'entry_form' && ($EE->input->get('channel_id') === '30' || $EE->input->get('channel_id') === '31')) {
$additionalJS = "$('#cat_group_container_15').find('input[type=checkbox]').prop('type','radio');";
}
//If there is additional JS, add it
if($additionalJS !== '') {
$EE->cp->add_to_head('<script type="text/javascript">$(document).ready(function() { ' . $additionalJS . '});</script>');
}
//Remove the tab
$this->sections[] = '<script type="text/javascript">$("#accessoryTabs a.viget").parent().remove();</script>';
}
// ----------------------------------------------------------------
}
/* End of file acc.viget.php */
/* Location: /system/expressionengine/third_party/viget/acc.viget.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment