hibbitts-design / grav-theme-quark-open-publishing

A customized version of the Quark theme for open publishing and blogging. Includes Git Sync and 'chromeless' content display for seamless embedding.
http://demo.hibbittsdesign.org/grav-open-publishing-quark/
MIT License
21 stars 12 forks source link

Multiple blogs in a single site #11

Closed Sheco closed 5 years ago

Sheco commented 5 years ago

The theme supports multiple blogs per site, but there are a couple of things which I find a bit awkward...

When listing featured posts, it includes all featured posts in the current site, including posts from other blogs in the current site, I would expect it to only show the featured posts in the open blog.

This is handled in templates/blog.html.twig, line 56, switching the for loop with one similar to the one on line 61, but using if "featured" in child.taxonomy['tag'] would yield a better result.

Additionally, in the quark theme, I would change templates/partials/sidebar.html.twig, line 38, adding , children_only: true to the include options, so that the related tags only show the related tags to the open blog.

What do you guys think about this?

Are these sensible defaults? Can they be introduced with optional settings?

paulhibbitts commented 5 years ago

Hi @Sheco , this is something I've done some experiments on before and I've read a few suggestions from others along the way. I'd be interested in making the theme more multi-blog friendly, but be aware that the Archives Plugin right now only really supports one blog per site (from what I've seen - see below update though).

If you are interested, here is what I've got so far:

In blog.html.twig replace the current loop for featured posts with this:

{# display posts with 'featured' tag on current blog page - hibbittsdesign.org #}
{% for child in taxonomy.findTaxonomy({'tag': "featured"}) %}
    {% if child.path starts with page.path %}
         {% include 'partials/blog-list-item.html.twig' with {blog: page, page: child} %}
    {% endif %}
{% endfor %}

And in the sidebar your suggestion works great:

{% include 'partials/taxonomylist.html.twig' with {'base_url':new_base_url, 'taxonomy':'tag', children_only: true} %}

If you can please test these changes and let me know if they work as expected for you.

Thanks, Paul

UPDATE: It looks like you can get the Archives Plugin more compatible with multiple blogs by using this filter (instead of a taxonomy):

filters:
    - '@self'
Sheco commented 5 years ago

Thanks for the feedback, what do you think about the following commit?

https://github.com/Sheco/grav-theme-quark-open-publishing/commit/f618a5b032685586e7be57d347064bd53ac54fa6

It implements these changes, but they are optional, hooking into the taxonomy plugin's settings, if children_only is set, then the blog posts and related tags will be limited to the post's children's taxonomy.

This way, by default it keeps the same behavior the theme currently has, but setting children_only leads to a better multi-blog experience, IMO.

Or maybe it should use a grav-theme-quark-open-publishing theme config option?

Sheco commented 5 years ago

I haven't yet looked into the filters: @self thing you mentioned in your update.

paulhibbitts commented 5 years ago

Thanks very much @Sheco - based on my tests with the Twig I shared earlier the change seems to be pretty transparent for existing (single) blog sites and multiple blog sites - if possible, I'd like to avoid needing additional options and have it "just work".

Do you see any issues with the changes I shared for existing (i.e. single) vs. multiple blog sites? I can make a new branch and commit the changes for you to also try from there.

Sheco commented 5 years ago

I personally think the changes are very reasonable defaults, but I haven't checked the Archive functionality so I wouldn't be able to comment on whether that would still work fine.

The changes you proposed are just what I was looking for.

paulhibbitts commented 5 years ago

I've just released the update with these changes @Sheco , if you get a chance to try it let me know how things go.