thathoff / kirby-git-content

Commit and Push changes made via the Panel
MIT License
138 stars 20 forks source link

Custom Path and some other options not settable #103

Open samyouel opened 10 months ago

samyouel commented 10 months ago

Hey! I'm on a multipage setup, where I define the root paths for the content folders etc in the /index.php file like so:

  $kirby = new Kirby([
    'roots' => [
      ...
      'content'  => $dynamic_directory . '/content',
      ...
    ],
  ]);

Now I set the content folder path in the settings (in the ready part of the settings, so the dynamic kirby root for content is available) :

'ready' => function ($kirby) {
    return [
    'thathoff.git-content.path' => $kirby->root("content"),
    ]},

Now the Problem

The settings are completely ignored by the plugin, in the same way the settings for commitMessage and menuLabel (maybe even more that's the ones I checked). Some of the settings, like commit, or pull are taken from the settings.

At first I thought it might be because of the ready part in my settings but even without that the custom path is not recognised.

In the constructor in site/plugins/git-content/src/KirbyGitHelper.php:24~29 it says:

    public function __construct($repoPath = false)
    {
        $this->kirby = kirby();
        $this->repoPath = $repoPath ? $repoPath : option('thathoff.git-content.path', $this->kirby->root("content"));
        $this->commitMessageTemplate = option('thathoff.git-content.commitMessage', ':action:(:item:): :url:');
    }

It seems like this is fired too early in the chain, even before the settings from the config.php are read.

-> Can you reproduce?

I would appreciate it if this works :) Thank you!

thathoff commented 10 months ago

Yes setting the options in the ready hook is not supported as the plugin already initialises the KirbyGit class when being loaded. But, the plugin should use the content folder automatically. And it did in all cases I’ve used a different / dynamic content folder. So from my point of view the problem is something different. 🤔

samyouel commented 8 months ago

Okay, so the ready won't be able to work. Cool, at least that makes sense.

I've tried this again and it's actually still not working. In the meantime I've altered the plugin's source file, but that's obviously not a solution. Would be cool to find a solution here. Thank you!