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

Data in Admin, display on site

Started by Daniel Katić 7 years ago · 2 replies · 533 views
7 years ago

Hi,

I'm new to grav and enjoying it so far.. I have a question.

In admin I need to add option Apartments, this should contain collections of apartments..
So a single apartment should have Id, Name, description, images.
In admin I need to have the option to add as much of them as needed and also to delete them.
On the site I will display apartments in descending order, similar to a list of blog posts.

Can someone point me a way to do this that is straightforward and explain since I can't find any examples of something similar?

Thank you.

7 years ago

Hi,

for anyone who is looking for some answers, i managed to get around it.

So in pages i created an apartments folder and inside of that every individual apartment goes. In the theme whatever you named your .md file you can put the same file in templates (only .html.twih extension).

To be able to add apartments via admin, in /user/blueprints/pages i created apartment.yaml and apartments.yaml files. There i added form elements that I need.

Later in my templates i would select all appartments like this:
{% for apartment in page.find('/apartments').children %}
...
{% endfor %}

Like this I can configure apartments as a whole, and also add as much of them individually as I need.

It's a little hard to get used to the fact that there is no database, more so if you come from Laravel or simmilar frameworks like I do, 😃

BR, Daniel.

👍 1
7 years ago

Thanks for sharing your solution. The forum does not appear to be very active.

👍 1

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1144 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago