Created
September 6, 2011 18:46
-
-
Save rsanchez/1198583 to your computer and use it in GitHub Desktop.
cp_js_end referer
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 | |
class My_ext { | |
/* blah blah blah */ | |
public function cp_js_end() | |
{ | |
//be courteous to other users of this hook | |
$str = $this->EE->extensions->last_call; | |
$this->EE->load->helper('array'); | |
//we need to look at the referring page, this script is loaded in it's own request | |
parse_str(parse_url(@$_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $get); | |
$controller = element('C', $get); | |
$method = element('M', $get); | |
if ($controller === 'content_publish' && $method === 'entry_form') | |
{ | |
//bingo! we're on the publish page | |
$str .= ' | |
$(document).ready(function(){ | |
//EMBIGGEN MY TITLE! | |
$("input[name=title]").css("font-size", "80px"); | |
}); | |
'; | |
} | |
return $str; | |
} | |
} |
Missing a semi-colon after $method = element('M', $get) - was getting a white screen and just figured that out!
Beautiful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script that is created using cp_js_end is loaded externally, which means that
will not work as you might expect. You've got to look back to the referring page's query string to ascertain which CP page is currently loaded.