Left Admin Menu

Keep original - Left Admin Menu

Keep original

by azpro » Sun Sep 17, 2023 10:44 am

@zipurman

Hi! Great addon - thanks!

I am using it in 1.0.8.20 - But I don't like to overwrite the original hMenu - so I renamed to vMenu. I also added a function so I can switch from hMenu to vMenu. I am aware your code can switch between original horizontal and vertical - but for development purposes I need te be able to switch the files.

I added this function to your file:

Code: Select all

	
	    public function get_switch_value() { //   ADDED
		 global $use_switch; 
	     $use_switch = true; /// sets use of vMenu or hMenu 
         return $use_switch;
        }       
And then added to all your listen_ functions (4x) - EG :

Code: Select all

  public function listen_injectBodyStart() {
    global $use_switch;
	if($this->get_switch_value()  == true){ 
And added to the original hMenu function listen_injectBodyStart:

Code: Select all

  	
      public function listen_injectBodyStart() {  	
  	  global $use_switch; 
	  if($use_switch == false){ //   ADDED
But now i still need to make a change to original hMenu - which I don't like.

Is there another way to do this?

Thanks!
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Contact:

Re: Keep original

by zipurman » Sun Sep 17, 2023 3:57 pm

I don't know of a way to do this without making some kind of core changes somewhere. I also have a mod I wrote that disables hooks for testing ... it would work as you could disable the original hmenu ... however, it still requires core changes.
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Contact:

Re: Keep original

by azpro » Sun Sep 17, 2023 4:33 pm

Thanks!
zipurman wrote:I don't know of a way to do this without making some kind of core changes somewhere. I also have a mod I wrote that disables hooks for testing ... it would work as you could disable the original hmenu ... however, it still requires core changes.
Yep - I think so ... I did some more testing using the templates/default/includes/hooks/admin/siteWide folder and the override folder - but this does not seem to work.


Maybe @ecartz has an idea on this?

Would be nice to have "some" templating feature for admin.

Is this mod that disables hooks for testing you made available?
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Contact:

Re: Keep original

by zipurman » Sun Sep 17, 2023 5:00 pm

azpro wrote:Is this mod that disables hooks for testing you made available?
Not currently. If you wanted to do it manually:

Create a file: _core/disabled_hooks.php

Code: Select all

    $disabled_hooks = [
        'hook_admin_siteWide_hMenu'     => 1,
        'hook_shop_product_info_imageZoom'      => 1,
        ];
You can change the above to 0 as a value for each to not disable it.

Then change core file: includes/system/versioned/1.0.8.1/hooks.php

Code: Select all

public function register( $group ) {

            $group = basename( $group );

            //BUG START HACK
            include DIR_FS_CATALOG . '/_core/disabled_hooks.php';
            //BUG END HACK

            $files = [];
            foreach ( $this->hook_directories as $directory ) {
                $this->register_directory( "$directory$group", $files );
            }

            foreach ( $files as $file ) {
                $pathinfo = pathinfo( $file );
                if ( 'php' === $pathinfo['extension'] ) {
                    $class = "hook_{$this->_site}_{$group}_{$pathinfo['filename']}";

                    //BUG START HACK
                    if ( empty( $disabled_hooks[ $class ] ) ) {
                        //BUG END HACK
                        foreach ( get_class_methods( Guarantor::ensure_global( $class ) ) as $method ) {
                            if ( substr( $method, 0, $this->prefix_length ) === self::PREFIX ) {
                                $action                                                                                   = substr( $method, $this->prefix_length );
                                Guarantor::guarantee_all( $this->_hooks, $this->_site, $action )[ $pathinfo['filename'] ] = [
                                    $GLOBALS[ $class ],
                                    $method,
                                ];
                            }
                        }

                    }
                }
            }

            $this->load( $group );
        }
This code is for 1.0.8.20
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Contact:

Re: Keep original

by zipurman » Sun Sep 17, 2023 5:03 pm

azpro wrote: Maybe @ecartz has an idea on this?
BTW, you cannot TAG users in this area. You'd have to ask ecartz via PM or create a discussion on the main forums. If you do that, do not make it addon specific as addon questions need to be here ;)
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Contact:

Re: Keep original

by azpro » Sun Sep 17, 2023 7:10 pm

Aha - Thanks! made a post in the forum :D
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Contact:

Re: Keep original

by Kofod95 » Mon Sep 18, 2023 5:55 am

zipurman wrote: Then change core file: includes/system/versioned/1.0.8.1/hooks.php
Would this change not be do-able through class-override? Just asking out of curiosity, so please forgive me if the question is stupid or misplaced!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Contact:

Re: Keep original

by zipurman » Mon Sep 18, 2023 5:59 am

It maybe possible. I have not tried overriding system/versiond classes. Just easier to adjust the core in this case. If you did a core update that overrode this file, you could just re-add the edits to the new file. I don't like overriding this kind of files as if an update was to happen, the file would remain and would likely break the new version as hooks.php is critical to be the same as the version you are running.
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Contact:

Re: Keep original

by Kofod95 » Mon Sep 18, 2023 6:59 am

Thank you very much for taking the time to explain! That makes sense and confirms a caution I've had to override too many classes.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Contact:

Re: Keep original

by azpro » Mon Sep 18, 2023 8:41 am

I have made a (quick and dirty) new file (modules_files.php) to give me an overview of all the current running files and hooks.

So when I am changing something (copy file - rename - update etc) I can check what the running file is so I am sure I am editing the right file.

I don't have access now to the code - but I think it is :
echo '<pre>';
print_r($_GLOBALS['class_index'])
I will check later today whether this was the code. EDIT $_GLOBALS['class_index']


This probably can be done much better - input appreceated!
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Contact: