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.

Support

Set page frontmatter per link

Started by Paul Richter 7 years ago · 1 replies · 394 views
7 years ago

Hi everyone,

I am trying to implement a simple function but am unsure on how to best do it. Basically I want to display a link on certain pages that, when clicked on adds the current user to the page frontmatter.

Is it possible to do this in twig? If not, do I need a custom plugin? I would appreciate if someone could give me some pointers on how to best solve this.

Thanks in advance,
Paul R.

7 years ago

I think you'll need to create a plugin for that. My route would be to setup a Grav form which submits via Ajax and let the plugin handle the onFormProcessed() event to add the logged in(!) user's username or full name to that page frontmatter and save that file.

Maybe you can re-use code from the Add Page by Form Plugin.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 90 48 minutes ago
Support · by Anna, 3 days ago
2 92 22 hours ago
Support · by Justin Young, 23 hours ago
1 40 22 hours ago
Support · by Duc , 1 week ago
2 98 6 days ago
Support · by Colin Hume, 1 week ago
2 90 6 days ago