Overriding header_required.php possible?

Permalink
I had to edit the /concrete/elements/header_required.php file for the site I'm working on and I moved it to the /elements folder under the root but it's not overriding. does this work in the latest version or is it still to come?

I don't mind leaving it in the concrete/elements folder but it would help for updating if it wasn't in there.

jelthure
 
ScottC replied on at Permalink Reply
ScottC
I looked at the loader.php located in concrete/libraries/loader.php and in what I am running Concrete5 5.1, @ line 67 which is the Loader::element:

public function element($file, $args = null) {
         if (is_array($args)) {
            extract($args);
         }
         if (file_exists(DIR_FILES_ELEMENTS_CORE . '/' . $file . '.php')) {
            include(DIR_FILES_ELEMENTS_CORE . '/' . $file . '.php');
         } else {
            include(DIR_FILES_ELEMENTS . '/' . $file . '.php');
         }
      }


So it looks like it is looking for the header_required in core as in inside the concrete folder heirarchy, if it isn't there then it loads the outside the concrete directory version, the one that is all dressed up with no date.

This isn't how I would think it should function which makes me think that I almost have to be wrong!

You could swap the DIR_FILES_ELEMENTS and the DIR_FILES_ELEMENTS_CORE in the if statement and get the desired result for now, but then again you'd have to do that everytime :)

I haven't messed with overriding php files with ones outside the concrete directory so this is all theoretical.

If I am entirely wrong which is entirely possible please let me know. I know Remo will!

edit: same syntax in new release.

-Scott

p.s. Hi Remo
jelthure replied on at Permalink Reply
jelthure
I found that it's defined in /concrete/config/base.php at line 72 or so:
# Path to the core files shared between all concrete 5 installations
define('DIR_BASE_CORE', dirname(__FILE__) . '/..');
# Path to the base directory of THIS install
define('DIR_BASE', dirname($_SERVER['SCRIPT_FILENAME']));


I think I'll just edit the header_required.php under the concrete's elements folder and put a backup in the root's.

Thanks for the response Scott!
andrew replied on at Permalink Reply
andrew
That's weird. It _should_ behave exactly as you assumed it would.

In the meantime I would advise just to edit the concrete/elements/header_required.php one and keep a backup, like you're doing. But I'll investigate this one, since it looks to be a bug.
ringo replied on at Permalink Reply
hi guys, is it possible to override any files which are contained in the elements folder? I want to know does it work the same way as codeignitor or other php frameworks in that it will look in the root folders first and if they are empty then it will look at the folders inside the /concrete subdirectory? I need to update the header_required element but don't want to do it in the concrete/elements folder as it will be changed by upgrades like the above thread mentions. What is the standard practice for overriding files? Thanks
frz replied on at Permalink Reply
frz
you got it.
ringo replied on at Permalink Reply
thanks for quick reply frz