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.

Forms & Blueprints

Profile page variables

Started by Erdinc 9 years ago · 5 replies · 1337 views
9 years ago

Hi,
I made a login based profile pages in my site. The users which register can collect (add) the website content data in their profile pages. In this case I don't know how to do it :). Is there any documentation or suggestions with that? how can I manage the "grav.user" data or any of the variables and write them into yaml user data. thanks

9 years ago

The user adds this data when registering, or once logged in there's a form to do that?

Which kind of data does a user enter?

9 years ago

this website hadipisir.com i like to add the recipes which users like to add their profile page ;)

9 years ago

You need

1) create a form that will only be shown to logged in users (using the Login Plugin)

2) upon form submission, store this data in the user/data/recipes/ folder, one YAML file for each user. You can see how the Comments plugin achieves this same operation using the onFormProcessed event in https://github.com/getgrav/grav-plugin-comments/blob/develop/comments.php#L178-L245.

The only difference is that Comments has one YAML file for each page, but you'd rather have one per each user

3) in your plugin, expose a "recipes" variable using Twig. Example of how Comments does: https://github.com/getgrav/grav-plugin-comments/blob/develop/comments.php#L75-L78

9 years ago

thanks a lot @flavio :vulcan_salute:

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1138 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 62 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 136 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 130 7 months ago