kirby-git-content icon indicating copy to clipboard operation
kirby-git-content copied to clipboard

Custom Path and some other options not settable

Open samyouel opened this issue 2 years ago • 6 comments

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!

samyouel avatar Jan 12 '24 11:01 samyouel

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. 🤔

thathoff avatar Jan 12 '24 15:01 thathoff

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!

samyouel avatar Mar 01 '24 15:03 samyouel