How to change things in Admin

Open to all! Ask other shopowners for help.
Dan Cole
Senior Contributor
Posts: 498
Joined: Fri Oct 25, 2019 2:14 pm
Phoenix Version: 1.0.8.21
Has thanked: 67 times
Been thanked: 61 times

How to change things in Admin

Post by Dan Cole »

@burt
Gary can you talk a little bit about how to make changes to admin files and protect the changes from being overridden on updates? I recently installed a new version of Phoenix to use as a test/staging site that will eventually end up replacing my older Phoenix live site. I'd like to make all my updates to the staging site in such a way that I can eliminate as much work as possible as I move along with additional updates. I understand how to handle changes on the shop side but I'm not sure if the same sort of approach will work for the admin files. As an example I was just updating the modal size used in /XXXadminXXX/includes/actions/outgoing/infoboxes/default.php to add modal-lg to the modal-dialog class. A pretty simple change but I want it preserved for the future and would like to start off using the best practice when making changes like this.

Dan
Last edited by Dan Cole on Fri Mar 20, 2026 9:02 pm, edited 1 time in total.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Omar_one
Senior Contributor
Posts: 676
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Adding Images to Index and CSS not working on Mobile

Post by Omar_one »

Dan Cole wrote: Fri Mar 20, 2026 3:42 pm @burt
Gary can you talk a little bit about how to make changes to admin files and protect the changes from being overridden on updates? I recently installed a new version of Phoenix to use as a test/staging site that will eventually end up replacing my older Phoenix live site. I'd like to make all my updates to the staging site in such a way that I can eliminate as much work as possible as I move along with additional updates. I understand how to handle changes on the shop side but I'm not sure if the same sort of approach will work for the admin files. As an example I was just updating the modal size used in /XXXadminXXX/includes/actions/outgoing/infoboxes/default.php to add modal-lg to the modal-dialog class. A pretty simple change but I want it preserved for the future and would like to start off using the best practice when making changes like this.

Dan
@burt maybe move this to a new topic

@Dan Cole here any example
- use a JavaScript hook ( Adds the modal-lg) and centering without core edits)

Code: Select all

<script>
  /**
   * Automatically upgrades the modal classes without touching core PHP
   */
  document.addEventListener("DOMContentLoaded", function() {
    const modalDialog = document.querySelector('#emailModal .modal-dialog');
    if (modalDialog) {
        // Adds the modal (lg) and centering without core edits
        modalDialog.classList.add('modal-lg', 'modal-dialog-centered');
    }
  });
</script>
here is the whole hook

Code: Select all

<?php
class hook_admin_outgoing_inline_css {
  
 public function listen_injectSiteEnd() {
       
        $admin_css =  <<<EOD
<style>
    /* Premium "Midnight & Cyan" Theme */
    #emailModal .modal-content {
        border: none;
        border-radius: 24px;
        box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
        overflow: hidden;
    }

    #emailModal .modal-header {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
        color: #f8fafc;
        padding: 1.5rem 2rem;
        border-bottom: 4px solid #38bdf8; /* Nice Cyan accent */
    }

    #emailModal .modal-title {
        font-weight: 800;
        font-size: 1.4rem;
    }

    #emailModal .btn-close {
        filter: invert(1) brightness(200%);
        opacity: 0.8;
    }

    #emailModal .modal-body {
        padding: 2.5rem;
        font-size: 1.15rem;
        line-height: 1.7;
        color: #334155;
    }
</style>

<script>
  /**
   * Automatically upgrades the modal classes without touching core PHP
   */
  document.addEventListener("DOMContentLoaded", function() {
    const modalDialog = document.querySelector('#emailModal .modal-dialog');
    if (modalDialog) {
        // Adds the modal (lg) and centering without core edits
        modalDialog.classList.add('modal-lg', 'modal-dialog-centered');
    }
  });
</script>
EOD;
 
        return $admin_css;
    }
  }

here how it look
You do not have the required permissions to view the files attached to this post.
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Adding Images to Index and CSS not working on Mobile

Post by burt »

I will separate this out so as not to confuse AstecModels (too much!)
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Adding Images to Index and CSS not working on Mobile

Post by burt »

The admin side is more about the following;

- new pages
- new views of existing pages
- hooks

Take for example the recent mod in the Co-op, that `keep an archive of outgoing emails`.

Class override to store sent emails rather than delete them.
Hook manipulates existing outgoing.php default view to remove archived emails
Hook manipulates existing outgoing.php page to add a Button to a new view
New View to show archived emails

It is true that we are still not at 100% no core code touching, but it is close.
Dan Cole
Senior Contributor
Posts: 498
Joined: Fri Oct 25, 2019 2:14 pm
Phoenix Version: 1.0.8.21
Has thanked: 67 times
Been thanked: 61 times

Re: How to change things in Admin

Post by Dan Cole »

I'm a bit confused (but that is my normal operating state :D) ....are you are saying you can't just override admin files?

Dan
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: How to change things in Admin

Post by burt »

Admin doesn’t support overrides like the catalog does. It's built around hooks and extending functionality, so you generally work that way and only touch core when there’s no alternative.

You might like to give an example of something you are trying to do?
I am not here to build for you.
I am here to build with you. Let's help each other.
Dan Cole
Senior Contributor
Posts: 498
Joined: Fri Oct 25, 2019 2:14 pm
Phoenix Version: 1.0.8.21
Has thanked: 67 times
Been thanked: 61 times

Re: How to change things in Admin

Post by Dan Cole »

Thanks Gary. Here is the example in my initial post. My goal (not for the example) was to simply preserved any changes I might make on an ongoing basis so I didn't lose them on future updates. Since we can't do simple overrides I'll probably set up a pretend override directory structure for the admin side and copy files that I change there so they aren't lost and then I can simply pull them into any new versions of Phoenix that I install. It would probably allow me to see what fails on the updates as well, so maybe that'll be a good way forward.
As an example I was just updating the modal size used in /XXXadminXXX/includes/actions/outgoing/infoboxes/default.php to add modal-lg to the modal-dialog class. A pretty simple change but I want it preserved for the future and would like to start off using the best practice when making changes like this.
Dan
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: How to change things in Admin

Post by burt »

Omar gave a solution for that :?: :!: :?: :+1:

Do you have a `harder` example ?
I am not here to build for you.
I am here to build with you. Let's help each other.
Dan Cole
Senior Contributor
Posts: 498
Joined: Fri Oct 25, 2019 2:14 pm
Phoenix Version: 1.0.8.21
Has thanked: 67 times
Been thanked: 61 times

Re: How to change things in Admin

Post by Dan Cole »

@Omar_one Thanks.
use a JavaScript hook ( Adds the modal-lg) and centering without core edits)
From my point of view that's a little over the top for such a simple change and I think I'll just try my pretend override directory approach to keep track of what changes I make on the admin side of things.

I appreciate you and your taking to time to post. Thanks again.

Dan
Dan Cole
Senior Contributor
Posts: 498
Joined: Fri Oct 25, 2019 2:14 pm
Phoenix Version: 1.0.8.21
Has thanked: 67 times
Been thanked: 61 times

Re: How to change things in Admin

Post by Dan Cole »

Do you have a `harder` example ?
Not of the top of my head but I've made lots of them (maybe even more than on the shop side) and will no doubt come across them as my new staging site evolves. I think a combination of hooks and my simpleton approach will work fine for me, if I can remember to copy over the files when needed. :o

Dan


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply