Jump to content
a-ok

Adding a favicon to the admin/CMS

Recommended Posts

Hi folks,

Quick one. Is it possible to add a favicon to the admin/CMS area? Without messing with anything core?

Thanks,

R

Share this post


Link to post
Share on other sites

I worked it out. Go to /site/templates/admin.php and add in (above the controller.php require)

<?php $config->styles->add($config->urls->templates . "favicon.ico?t=" . time()); ?>
  • Like 2

Share this post


Link to post
Share on other sites

I decided to mark this as unsolved as adding this caused a few loading issues on the CMS on the pages dashboard (see screenshot) – any other thoughts?

unnamed.jpg

Share this post


Link to post
Share on other sites

Hi Richard, I don't know if you still need this, but I managed to use a favicon without any issues.

First: install the Reno admin theme
Second: navigate to wire/modules/AdminTheme/AdminThemeReno/default.php
Third: paste your favicon links into the <head>-area in my case line 56

 

    <!-- Favicons -->
    <link rel="apple-touch-icon" sizes="57x57" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="<?php echo $config->urls->templates?>favicons/apple-touch-icon-180x180.png">
    <link rel="icon" type="image/png" href="<?php echo $config->urls->templates?>favicons/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="<?php echo $config->urls->templates?>favicons/favicon-194x194.png" sizes="194x194">
    <link rel="icon" type="image/png" href="<?php echo $config->urls->templates?>favicons/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="<?php echo $config->urls->templates?>favicons/android-chrome-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="<?php echo $config->urls->templates?>favicons/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="<?php echo $config->urls->templates?>favicons/manifest.json">
    <link rel="mask-icon" href="<?php echo $config->urls->templates?>favicons/safari-pinned-tab.svg" color="#5bbad5">
    <link rel="shortcut icon" href="<?php echo $config->urls->templates?>favicons/favicon.ico">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="<?php echo $config->urls->templates?>favicons/mstile-144x144.png">
    <meta name="msapplication-config" content="<?php echo $config->urls->templates?>favicons/browserconfig.xml">
    <meta name="theme-color" content="#ffffff">

Share this post


Link to post
Share on other sites

Maybe the admin themes could feature a hook in that place so it could be edited without modifying core files.

  • Like 3

Share this post


Link to post
Share on other sites

How about replacing PW logo with my company's logo (branding) without modifying the admin theme?

Share this post


Link to post
Share on other sites

Maybe the admin themes could feature a hook in that place so it could be edited without modifying core files.

Or maybe search in a /site/somefolder/ first for a favicon and use that if one found?

Share this post


Link to post
Share on other sites

You could do this in admin.php (above the line that brings in controller.php):

$wire->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
  $extras = $event->return;
  $extras['head'] .= '<link rel="shortcut icon" href="'.wire('config')->urls->templates.'favicon.png">';
  $event->return = $extras;
});
  • Like 8
  • Thanks 1

Share this post


Link to post
Share on other sites

I don't know is this topic is still alive?

Just put this  line in the header of _main.php, close your browser and restart or refresh (CTRL-F5) a few times and the favicon appears.

	<link rel="icon" href="<?=urls()->templates?>styles/images/favicon.ico">

 

  • Like 1

Share this post


Link to post
Share on other sites

@hansv The admin backend is not working with _main.php. What you mean is to set the favicon in the frontend.

Jonathans example looks good for me.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you @Robin S for that snippet!

One can also use fontawesome icons with this service: https://gauger.io/fonticon/

Just download the .ico to your website and include it like robin showed above:

$this->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
	$extras = $event->return;
	$extras['head'] .= '<link rel="shortcut icon" href="/site/templates/img/favicon.ico">';
	$event->return = $extras;
});

🙂 

Share this post


Link to post
Share on other sites

It's even easier.

Just add a favicon.ico (backend) to and a favicon.png (website) to your web root.

For the real website you define something like <link rel="shortcut icon" href="/favicon.png" type="image/png">

While the website shows your .png the backend will show your .ico.

Share this post


Link to post
Share on other sites

Sorry, don't get what you are saying... Where do we have to add the favicon.ico to be desplayed in the backend? 🙂 

Share this post


Link to post
Share on other sites

Thx for clarifying. That doesn't work here on Win10 + Chrome 😐 I don't find any occurances of "favicon.ico" in the wire folder, so I guess your browser is making you see the favicon, not ProcessWire?

Share this post


Link to post
Share on other sites

Weird... the favicon.ico thing works like this:

The browser looks in certain places for certain files.

The favicon.ico is expected here: https://www.domain.tld/favicon.ico and will be displayed if it exists.

You can... nonetheless... define an alternative file as described above to change default behaviour or to show another file like a .png

Sometimes browsers are kind of lazy and don't look for new files they either haven't found for a while or have already cached. So using another browser or adding a bookmark to your bookmark bar can help to trigger a reload/refresh.

  • Like 1

Share this post


Link to post
Share on other sites

@wbmnfktr  thx, this is working (in Chrome, Win10). fine after cleaning browser-cache and closing browser-tabs, 

Share this post


Link to post
Share on other sites

I've of course tried it in an incognito window... I'll try that next time with another installation 🙂 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By JeevanisM
      Hello All,
      Recently I have read a series of articles about some new terms like Headless CMS, Hybrid CMS and Digital Experience Platforms ( DXP). I cannot get a clear picture of these but I could understand that these are different from the traditional CMS as we use now, at least in theoretical level. Does any one here have any better understanding on these topics ? may be what / how we can apply these on the processwire CMS ?
       
      just for the talk
       
    • By Clément Lambelet
      Hey!
      I've been working on a Processwire installation (3.0.123) for a few days now and I must have made a big mistake this morning because the links in the admin's main menu no longer appear.
      This is not related to the admin theme, because the bug occurs with all themes (Default, Reno, Uikit).
      I tried to reinstall with the dev version (3.0.136), but the problem is still there. I also uninstalled all the modules I had added, without success. There is no error in the js console. 
      I still can access/view/edit the pages  by going through the admin/page list.
      Thanks in advance for your help!


    • By MateThemes
      Hello everyone!
      I have searched the forum for quite a long time and I tried some solutions for my topic but nothing seems to work.
      I need to create a Settings Page and for a native feeling I want to create it under the main navigation on top. The settings page should hold the Main Logo, some styling and other settings. As I said nothing seems to work for me. I tried to create a Page under Admin with Admin Template and ProcessPageEdit but then I can't assign an image field. 
      I don't want to write a module because it is to much work for only 3 settings.
      I hope someone of the forum could help me out!
      Have a nice day!
    • By BitPoet
      Inspired by this thread with a little nugget based on AOS by @benbyf to visually distinguish development systems from production ones, I wrote a small module that does the same and lets you adapt colors and text.
      Link to the github repo:
      AdminDevModeColors
      Version 0.0.1 is still very alpha and only tested on PW 3.0.124.
      Description
      This module lets you change the color for the top toolbar and add a small piece of text for development systems, so you are immediately you aren't working on production (and vice versa). The adaptions are made through pure CSS and applied if either the "Enable DEV mode" checkbox in the module's configuration is checked or the property $config->devMode is set to true in site/config.php.
      Works with Default, Reno and Uikit admin themes (though probably needs a lot of testing with different versions still).
      Since a screenshot says more than thousand words...
      Production system (unchanged):

      Dev system (Default admin theme):

      Dev system (Reno admin theme):

      Dev system (Uikit admin theme):

      Feel free to leave any feedback here and report any problems either in this thread or the github issue tracker.
       
    • By SwimToWin
      The basic Processwire workflow assumes that I (as an Editor) want to save new Pages in draft mode - and therefore new pages are always set to unpublished by default. To publish the page, it is necessary to actively press "Publish", otherwise the Page will not be visible.
      The workflow is:
      Add new Page Status is now "Unpublished: Not visible on site." Press Publish - the page is now visible on site I want to publish pages right away (without having to press Publish).
      Where is that configured?
      ProcessWire 3.0.123
      Uikit v3 admin theme (0.3.0)
×
×
  • Create New...