PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
255 stars 49 forks source link

Missing some documentation and project status? #335

Open ohnonot opened 5 years ago

ohnonot commented 5 years ago

Hello, thank you for this lightweight, fast flat file CMS!

I have been using pico for some time, but my blog has grown to ~70 pages and now there's a definite increase in loading time.
Not so with Phile! I was able to re-use some of my pico templates and can make a direct comparison. Much faster.

Trying to port all templates over to Phile, I miss some documentation, most of all a list of all variables available to twig, like here.

Questions:

Is it possible to access URL or form parameters inside twig templates, e.g. example.com/index?page=3 could become {{ url_param(page) }} or so?

I would like to override some settings in some plugins, namely phpFastCache and templateTwig. This is possible inside each one's own config.php, but wouldn't it be cleaner to do this in the global config.php? Currently I cannot define a cache dir or override twig's template extension. In other words, these settings inside config/config.php have no effect at all: $config['plugins']['phile\\phpFastCache'] = ['path' => some/path'];
$config['plugins']['phile\\templateTwig'] = ['template-extension' => 'twig'];

Lastly:

What is the overall status of this project? Most activity seems to have been 5 years ago... Would you recommend that I switch to Phile fulltime?

Any chance of merging your efforts with the now much more active picocms? They are aware of the performance problems and want to do something about it.

Schlaefer commented 5 years ago

Hello

Not so with Phile! I was able to re-use some of my pico templates and can make a direct comparison. Much faster.

Great to hear. Performance is one of the advantages of Phile over Pico.

Trying to port all templates over to Phile, I miss some documentation, most of all a list of all variables available to twig, like here.

The landing page after the installation shows the available variables. See https://github.com/PhileCMS/Phile/blob/master/content/index.md#themes--templates

Is it possible to access URL or form parameters inside twig templates, e.g. example.com/index?page=3 could become {{ url_param(page) }} or so?

Phile doesn't use URL parameters and has no facilities or opinion about them. So bring your own implementation. A naive implementation for {{ url_param('page') }} using a plugin:

class Plugin extends \Phile\Plugin\AbstractPlugin
{
    protected $events = [
        'template_engine_registered' => 'templateEngineRegistered'
    ];

    public function templateEngineRegistered($eventData)
    {
        $function = new \Twig\TwigFunction('url_param', function ($param) {
            return filter_input(INPUT_GET, $param, FILTER_SANITIZE_SPECIAL_CHARS);
        });
        $eventData['engine']->addFunction($function);
    }
}

Currently I cannot define a cache dir or override twig's template extension. In other words, these settings inside config/config.php have no effect at all:

I'm not sure what's happening here, the order of precedence should be:

  1. config/config.php
  2. config/default.php
  3. Plugin config.php
  4. Plugin-Class

What is the overall status of this project? Most activity seems to have been 5 years ago... Would you recommend that I switch to Phile fulltime?

Should you switch to Phile? Hard to say. I have running sites on Phile for years now and I don't plan to switch them away. Maybe an update once a year and that's it; they just work. Phile does a few things and it does them exceptionally well (imho): performance and code flexibility (see the code above). If Phile scratches your itch, I say use it. But don't expect much further development. It sits in its niche doing what it does. You want more features out of the box? Use e.g. Grav. You want noob-friendly code and performance isn't an issue? Use Pico. You have no problem bringing a few lines of PHP code yourself to do whatever you want? Use Phile.

Any chance of merging your efforts with the now much more active picocms?

I believe Pico sits in a similar niche as Phile. People who are using Pico are fine with it, change doesn't fullfill any need and/or the backwards-compatibility breaking isn't worth it. Merging with Pico? I don't know how much you are able to merge without becoming the other, which is the change I believe nobody wants. But sure, it's OSS, if Pico picks up parts of Phile I'm all for it.