nextcloud / cms_pico

πŸ—ƒ Integrate Pico CMS and let your users manage their own websites
https://apps.nextcloud.com/apps/cms_pico
GNU Affero General Public License v3.0
134 stars 41 forks source link

Uncertain about how to import a custom theme #209

Closed sm8ps closed 1 year ago

sm8ps commented 1 year ago

I am trying to get the custom theme TagBlog working. It comes with an adapted version of plugin (TableOfContent) and does not contain any Javascript but is all done in Twig. So I stupidly suspected it should be simple to have it installed. (: Here is what I did:

cd nextcloud_data/appdata_*/cms_pico/themes
git clone https://notabug.org/ohnonot/tagblog
cd ../plugins
ln -s ../themes/tagblog/res/TableOfContent/
cd ../themes/tagblog
cp res/tagblog.yml ./tagblog/pico-theme.yml
cd includes
for file in *.example ; do cp -a $file  $(basename -s .example $file) ; done

The last step copies .twig.example-files to the respective .twig-files because the theme needs to access those. After adding the theme as well as the plugin, its style is applied and blog entries are shown, however there is no tag cloud visible which would be the whole point of this exercise.

I was wondering if the copying of tagblog.yml to pico-theme.yml does what I hope it to do. The instruction for plain Pico speak of copying tagblog.yml into <your pico install>/config/ which -- in my understanding -- does not make sense for Nextcloud. The file contains various configuration variables and I do not see any easy way to test any of them. Therefore I would be extremely glad to know if there is any hope of getting thins to work before blindly heading into any direction.

Thanks in advance for any support!

sm8ps commented 1 year ago

To clarify my question: Is it possible for a theme to define custom variables in pico-theme.yml and how can they be accessed in the Twig-files?

PhrozenByte commented 1 year ago

To clarify my question: Is it possible for a theme to define custom variables in pico-theme.yml and how can they be accessed in the Twig-files?

Yes. Config variables in pico-theme.yml are merged into $config['theme_config'], accessible in Twig via e.g. {{ config.theme_config.my_custom_config_variable }}. However, since this theme doesn't seem to know about pico-theme.yml, it was probably written for an older Pico version and rather expects this config file to be placed in Pico's global config dir below appdata_*/cms_pico/config (i.e. affecting all themes). I'd recommend editing the theme to rather use pico-theme.yml (you might wanna ask the theme developer for help, she/he might want to update the theme). See https://github.com/picocms/pico-theme/blob/master/pico-theme.yml for reference.

sm8ps commented 1 year ago

Great -- many thanks for this explanation! I am ready to adapt the theme to the Pico-CMS on Nextcloud frame. As the programming logic is already there, the handling of configuration variables was the first major roadblock.

If you don't mind, I would like to keep this issue open in case additional questions arise in this context.

Cheers!

mayamcdougall commented 1 year ago

I'm not familiar with the differences in running Pico for Nextcloud, but the instructions for TagBlog are actually referring to the fact that (traditional) Pico will load all .yml files in the config folder, not just config.yml (I have no idea if this is true in Pico for Nextcloud though).

So the intention was that adding this file to your config folder, would result in it acting like it was added to config.yml, but without having to actually merge the files.

@PhrozenByte answered your second question, but I think this is a better answer to your first.

The theme could definitely be updated to use a pico-theme.yml instead, which would streamline installation/configuration for new users. Updating it isn't strictly necessary though, especially if you just want to try it out first. Temporarily adding the contents of tagblog.yml to your config.yml should be more than enough to get it up and running (provided there are no other Nextcloud-related incompatibilities). πŸ˜‰

sm8ps commented 1 year ago

Thanks a lot @mayamcdougall for your insights! I was about to state here that I have the theme working. Thanks for your support, @PhrozenByte! In fact, one of the articles I wanted to have a blog for is the one describing how to use Pico on Nextcloud. The blog post is far from ready and I shall add your insights to it as well.

Moving res/tagblog.yml to pico-theme.yml was the key and the rest of it was simply a question of prepending some paths with {{base_url}} here and there. Comments, RSS, logo and coloring are not handled yet.

sm8ps commented 1 year ago

Closing the issue as solved.