We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Hook to use in CP on every page with all classes fully loaded?

Developer Preview

Derek Hogue's avatar
Derek Hogue
316 posts
9 years ago
Derek Hogue's avatar Derek Hogue

I’m working on a port of an EE2 add-on which injects some javascript into the footer of the CP in order to add some markup to the page (specifically, I need to inject markup and load javascript on the CP homepage). Previously I did this with an Accessory.

I’ve been trying to use sessions_end, but as I’m sure you know that is very, very limited (there are seemingly a tonne of framework features which aren’t ready to be used yet when that hook is called).

I did try the hack outlined somewhere here on the forums whereby you manually assign the session object to ee(), but even then, ee()->cp is was available (error thrown in the legacy Facade).

Is there a way forward here, or am I currently screwed with the death of Accessories?

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

sessions_end is a little confusingly named, since it’s the end of the Session class instantiation, and not the end of the session or late-game processing. So it’s actually nearly as early as sessions_start.

James is working on some things to allow customization of the CP homepage, primarily targeting things like this that people used to use Accessories for. Can you describe in more detail what you are wanting to display for the user? Having details on the use case will help us build that functionality in a way that’s more likely to meet your needs.

In the meantime can you use the cp_js_end hook?

       
Derek Hogue's avatar
Derek Hogue
316 posts
9 years ago
Derek Hogue's avatar Derek Hogue

I’ll try cp_js_end again - it didn’t work for me when I tried to port my old code over because it expected to be loaded directly in the footer via ee()->cp->add_to_foot(), which in my testing didn’t work inside of cp_js_end. I’ll try some refactoring there and see if I can get that hook to work.

It’s a new/different version of CP Analytics I’m working on.

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

That hook should be able to add JS directly, instead of the old add_to_foot(). In other words, returning your JavaScript as a string is expected.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.