Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Modifying Modular/partials Contents from Admin

Started by Muut Archive 10 years ago · 11 replies · 405 views
10 years ago

I'm just getting started with Grav (Coming from Wordpress theme dev) and so far, I'm loving the potential that I'm seeing with Grav. I have some questions though.
I've read a lot of the documentation and have been digging through a several of the skeletons to get an understanding. I'm hoping to be able to use this for simple sites that my clients can make chages to through the admin plugin.

  1. Is there a way to update the sidebar content without digging into the twig templates every time? My first thought would be to create a page template for sidebar (that isn't visible on the front end) that they could add specific content to and then include that template within the blog template.
  2. For the Modular pages, I'm seeing a lot of the skeletons setup with great styling and layouts but when looking at how they are built, it doesn't seem very user-friendly. For example, in the Holcyon Site skeleton, it looks like you have to modify the content in the different modules through their front matter. Is there a way to build that template so that the client could easily edit tha t content through the regular editor? In Wordpress Land it would be similar to a custom field or maybe a text widget area.

I don't mind getting my hands dirty or doing more research, but if you guys could point me in the right direction, that would be awesome :) Thanks!

10 years ago

Also, why are there no themes built with bourbon/bitters/neat? Maybe I can make a contribution to the community once I get my "sea legs!"

10 years ago

Hi,

1) Since Grav assumes nothing about the frontend, this must be handled by the theme. You can setup the theme to include a page, like you said, you can also add a setting to the theme blueprint to allow editing the sidebar content in the theme configuration.

2) Yes, Pages Blueprints are made for this. In short, any field you see in the Admin when you edit a page has been added to the Page blueprint. Any page type has different page blueprints, and the theme/plugins can add new ones.
See the system (default) pages blueprints and the blueprints provided by the Antimatter theme

3) As for the theme framework, no special reason - simply a theme choice :)

10 years ago

Ah, Awesome! Ok, so I played around with it a bit. and it's getting there. I have everything working properly except for the toggle option. I wanted to default it to "disabled" but whenever you enable it and save the page, when you refresh it is disabled again? What am I missing here?

From the blueprint:

YAML
         fields:
            page.header.optional_sidebar:
              type: toggle
              label: Include Sidebar on Page
              help: Toggle to enable sidebar on this page.
              hightlight: 1
              default: 0
              options:
                1: Enabled
                0: Disabled
              Validate:
                type: bool
10 years ago

That first "fields" part is in the right place in my code, the spacing just got off a little in the reply.

10 years ago

Looks ok apart from hightlight -> highlight, Validate -> validate, can you try with those little fixes in?

10 years ago

hi, you miss this line:
toggleable: true

10 years ago

I just tested it by adding "toggleable: true" to the blueprint. That adds a checkbox to the sidebar tab but it still doesn't change the fontmatter. What else could I be missing here?

10 years ago

I'm also stucked on that. We need somehow a variable that can be used in sidebar.html.twig. if we see the content of sidebar.html.twig, it uses variables from config.plugins. what we don't know is how to get a value of a blueprint's config which can be used in a twig file.

10 years ago

I used "if" statements in the twig file based on the blueprint/frontmatter. But understanding how to get it to play well with the admin interface has been difficult for me.

10 years ago

Just a thought, but have you tried to clear ALL cache? I have found that many small issues go away when doing this.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1123 9 years ago