getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
354 stars 227 forks source link

Question: Anything close to Views or Blocks in Grav? #1241

Open 40thpower opened 7 years ago

40thpower commented 7 years ago

Hello all, my first post here.

I've been learning Grav for the past few days, coming from a Drupal background. Liking Grav a lot so far. One thing I'm curious about is whether there is anything equivalent in Grav to Drupal's Views and Blocks?

It seems that Regions might be added to the page template as html section tags. A token of some kind might be used to pull in a Twig code snippet. A routine might be run to cycle through these snippets and display 10 at a time, etc.

I can understand how it might take some time for Grav to evolve, considering how long it took Drupal to reach maturity. I'd certainly be glad to pay for a powerful new module that added some useful features. Got to fund these projects somehow!

Also, why not incorporate an optional single-page database into Grav, one that could be easily copied, stored in xml format etc, if it enabled some cool database features without requiring the dread of managing a big database? I can see Grav becoming VERY popular, with or without these new features.

Thanks!

btopro commented 7 years ago

Same boat here (Drupal / Grav) Views no. nothing has views, go back and use Drupal ;)

Blocks though you are right on the regions aspect. It's a bit confusing but you can have sections of pages and things that show up places.

I'm sure you could rig something up where you could query some endpoint, that then reads off the available files in the right directory and returns info about them but Grav is more of a front-end / nice little micro-site stamper and what you laid out is ...well.. drupal :)

40thpower commented 7 years ago

Good news, btopro. Actually, I'm finding there are rough equivalents to Drupal's views and blocks. For example the skeleton site Open Publishing has the Blog section, which is 'page collection'. According to the docs, https://learn.getgrav.org/content/collections, collections are defined in the frontmatter under items:

content: items: '@self.children' order: by: date dir: desc limit: 10 pagination: true

And can be treated like an array, so the blog items can be displayed in a certain quantity, with a pager. Awesome!

Then there is also the 'modular page', which can list subitems like this in the frontmatter:

content: items: @self.modular order: custom:

This calls up each item in a list, much like a view.

Subitems can also be 'injected' into any other page you want, as many times as you like, just like blocks, as shown in the 04.module-page-inject page.

So I think there's plenty here to celebrate from a Drupal point of view. In fact once I get my project built I'm hoping to present it to my local Drupal user group.

Sorry for this basic lesson, to those who already know it. :) I mostly need to document it for my own purposes.

dimitrilongo commented 7 years ago

i'm not familiar with Drupal, but maybe something like widget https://github.com/sojimaxi/grav-plugin-widget may be interresting

mahagr commented 7 years ago

Also look at Gantry plugin as it has the concept of positions and particles, which allows you to create blocks to your site with a full configuration in admin -- and many particles can be written in 15-30 minutes as they just contain twig and yaml. Gantry particles also support AJAX.

Also, I'm slowly working towards moving concepts learned in Gantry back to Grav, which would allow much greater control for creating the site from smaller blocks. Some of the concept glasses are already in 2.0 branch, though they aren't used except in some private projects.

axel-rank commented 7 years ago

Can I use Gantry plugin with all Grav themes, or do i have to install a Gantry Theme (Hydrogen etc.) ?

mahagr commented 7 years ago

Those will only work in Gantry because of all the extra logic which is needed to make them work.