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

Modify a custom page header field

Started by Muut Archive 10 years ago · 6 replies · 727 views
10 years ago

Hello!
Is there a simply way to modify a custom page header field, something as simple as

PHP
$a_specific_page_markdown->set('header.custom_field') = $updated_value;

or even better with twig:

TWIG
{% a_specific_page.header.custom_field = updated_value %}

I've looked into the admin preparePage() function but I'm not skilled enough to use it for my purpose (and it updates the whole page, I just need to update a specific custom page header)

10 years ago

the first php line has no sense, but I hope you got the point :)

10 years ago

What are you trying to accomplish generally?

10 years ago

I have a collection of pages representing an item reference. I'd like to put a quantity custom field in the header and be able to update it from an admin page that lists all the items (pages) and let the user to modify the quantity.

10 years ago

Any idea? Or any plugin to point me out where I can get inspiration?

10 years ago

May I suggest an idea: do not put the quantity custom field in the header but save them in a data file.

Since each page has a slug, you may take inspiration from Star Ratings plugin. This plugin allows users to choose how much pleasure give to a post and records it in two files in the /user/data/star-ratings/
ips.json includes users IP, stars.json contains routes and satisfaction.

Users increase the amount that can be managed in admin

10 years ago

You can't highlight section header in std page layout. To change look and feel of page layout section use VF page.

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 1124 9 years ago