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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Adding page in Admin: Change default to blog & item

admin

Started by Endogen 9 years ago · 4 replies · 1135 views
9 years ago

How do i set the default "Add page" to parent page "blog" and page template to "item"? I'm writing a blog and basically all i do is creating blog posts and it's kind of annoying when i have to change that all the time manually.

BTW: I'm using the Admin plugin

9 years ago

Hi @endogen, you can set the default child page type for page, which should help you out a fair bit. In the page frontmatter of your Blog Markdown file, add the following:

child_type: item

The above assumes that the template for blog children are named "item", you theme might use another template name.

I do not remember if this is an option for the blog parent page in Admin, if it is it's likely under the "Advanced" tab when editing that page.

9 years ago

I do not remember if this is an option for the blog parent page in Admin, if it is it’s likely under the “Advanced” tab when editing that page.

It is! Thanks for the help :) Now the first step is done. Any idea how to set the default parent page for Add Page to blog?

9 years ago

I have not found any way to change the default parent page except to modify the YAML for the Admin Panel plugin, but this change can be lost when updating the Admin😕

Here is an example where I changed all new pages to default to the sidebarpage template:

File: \user\plugins\admin\blueprints\admin\pages\new.yaml

YAML
    name:
  type: select
  classes: fancy
  label: PLUGIN_ADMIN.PAGE_FILE
  help: PLUGIN_ADMIN.PAGE_FILE_HELP
  data-options@: '\Grav\Plugin\AdminPlugin::pagesTypes'
  #data-default@: '\Grav\Plugin\Admin\Admin::getLastPageName'
  default: 'sidebarpage'
  validate:
    required: true
9 years ago

Really helpful! Thanks for sharing

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 44 1 week ago
Plugins · by Xavier, 4 weeks ago
2 54 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1181 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 48 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 73 2 months ago