ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Add a meta tag to the CP

January 08, 2012 8:28pm

Subscribe [1]
  • #1 / Jan 08, 2012 8:28pm

    Blis Web Agency

    67 posts

    Just wondering if there is a extension hook which will allow me to add a meta tag to the head of the Control Panel. I’d rather not have to hack the core. This used to be possible with show_full_control_panel_start in EE1 but it looks like there’s not be a similar hook added to EE2.

  • #2 / Jan 09, 2012 11:25pm

    John Henry Donovan

    12339 posts

    Hi Blis Web Agency,

    Out of interest why do you need to add a meta tag to the control panel?

    There is no need to hack but you can make a copy of the default theme folder under themes/cp_themes/ and rename it to something else. Grab the file system/expressionengine/views/_shared/header.php and put it into your new theme folder. Edit it to include the meta tag. This will take preference.

    EE Docs : Customizing the Control Panel Theme

    Let us know if that helps

  • #3 / Jan 09, 2012 11:37pm

    Blis Web Agency

    67 posts

    Hi John,

    It’s a funny one - the client uses IE9 to access EE but have modified their Default OS install so that IE9 installs in IE7 compatibility mode… effectively making us work with IE7. I know that EE2 is meant to run ok on IE7 but some of the 3rd party add-ons we’re using certainly don’t like it. Given this, we wanted to add a Meta Tag to the CP head to make tell IE9 “not” to render the pages in compatibility mode.

    Using a custom theme sounds like an ideal way to do what I’m after. I assume that when I update EE I’ll have to update my customised header.php file still to reflect any new changes?

  • #4 / Jan 11, 2012 4:49am

    John Henry Donovan

    12339 posts

    Hi Blis Web Agency,

    I assume that when I update EE I’ll have to update my customised header.php file still to reflect any new changes?

    That is correct. I just tried a test there and found issue with it. SO let me just check with the devs on this one to see if this is still possible with PHP files as opposed to CSS

  • #5 / Jan 11, 2012 12:06pm

    Robin Sowell

    13255 posts

    Ah- yes, it should work.  Just be sure to:
    1. Create a new theme folder (don’t try to override by putting the view file in the default theme)
    2. Create a folder structure that mimics the ‘view’ folder- in this case, created a _shared folder and then put a copy of header.php in it.  Edit header.php as needed.
    3. Be sure to switch to your new theme!  Whee- I forgot to do that my first test and was like ‘why the heck doesn’t this work’.  Heh.

    And with a custom theme, you will keep a lookout for changes to view files- they should be posted in the update notes each release.  Not that the header is going to change very often, but if it does, you’ll want to update your custom theme. 

    You COULD do it w/an accessory showing in all cp pages, but I’d go custom cp theme route myself.  It’s easy to maintain since you only need to put the files you want to override in there.

    That do the trick?

  • #6 / Jan 11, 2012 6:02pm

    Blis Web Agency

    67 posts

    Hi Robin,

    Thanks for confirming these details, it does sound like the way we’ll go on this one.

    I am interested though about the idea of doing it with an accessory. Given what we need to do is output a “meta tag” in the header, it needs to be there when the page first loads (not after the DOM loads via Javascript) so that the browser processes it accordingly. I didn’t think this was achievable with an accessory but if it is I’d love to know a little bit more about how you’d do it as this would be a more preferable solution. Reason being, it would then remain effective despite CMS updates.

  • #7 / Jan 12, 2012 10:03am

    Robin Sowell

    13255 posts

    I’d go with the theme myself (the accessory would have to show on every page or you lose the header- but folks have used it as a way to get some js in there).  I’m pretty sure you could do it with add_to_head.  Eyeballs it… yes, I believe that would work.  But like I say- I THINK I’d go with the theme option unless I had a compelling reason not to.

    Make sense?

  • #8 / Jan 12, 2012 5:06pm

    Blis Web Agency

    67 posts

    Thanks Robin - add_to_head looks like it should do the trick too. I’m a little more fond of the idea of using an Accessory if possible because it keeps the upgrade process simpler. Still, nice know there are a couple of ways to do what we’re after. Thanks for your help.

  • #9 / Jan 12, 2012 5:32pm

    Robin Sowell

    13255 posts

    Indeed- it does have that benefit.  As long as you have control and know they aren’t going to disable the display anywhere, you should be good.  I’ve had a few cases where an accessory was clashing w/native js and just went in and removed the display from those pages in order to fix the error, so I can be a bit biased.

    But I will admit- you wouldn’t have to worry about the theme changing.  Or worse- if you wanted to actually use another theme, but had to hack it to get your metadata in there.

    Which is why- it’s always good to have options.  😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases