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

How to connect a database to a table in Grav

Started by Ton Haarmans 5 years ago · 24 replies · 3929 views
5 years ago

For a client I need to know the following:
There are tables on certain pages that need to be automatically filled and updated with data from a MySQL database. I have installed the Database and Views plugin. I have no clue how to connect the tables with the database. I am a front end designer... Could somebody help me? If this is not possible the client's choice for a CMS will be Drupal 8 😦 .

5 years ago

Didn't have to deal with DBs on Grav, but I'm afraid you still might have to do some coding. To get your connection. Also might find this article useful.

5 years ago

@TonHaarmans:
i need to know what code and where to put it

What I understand from the docs, you'd need to create a plugin, that would connect to your DB by using $this->grav['database'], which is initiated by Database plugin. Also in your plugin you probably could do most of the logic that is described in that article I posted

1 reply
5 years ago

Making a plugin! I will try. Never done that before...

5 years ago Ton Haarmans Thanks Karmalakas. I am not afraid of the coding, but i need to know what code and where t…

@TonHaarmans,
as @Karmalakas already stated, you will need to create a plugin that can connect to a mysql database - be aware that the database plugin that was mentioned only can connect to a sqlite DB.
for mysql, you will probably need symfony/doctrine.

1 reply
5 years ago

So the point would be for me: how to make the connection between the DB and a page or part of a page (like a table width different data in different table cells).

5 years ago

no, importing csv should be easy.

5 years ago

Yes, will try that!
The main Database of my client is written in Access. This can spit out a csv, which can be uploaded and then imported into Grav. If that can work, that would be awesome.

Suggested topics

Topic Participants Replies Views Activity
General · by jean-louis67, 3 weeks ago
2 308 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 311 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 265 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago