How to connect a database to a table in Grav

My client is a computer education company. They offer all kinds of courses. Every course gets its own page and in that page is a table with all the data, like course dates and places, software version, price, etc. He would like to have his central database to update the course data on the course pages on a regular basis. They now do it manually in a Drupal 7 site. I have convinced my client to move to Grav. But he has one condition: it must be possible to update the course data automatically… That’s it in a nutshell. I really hope this would be possible, for instance using csv…

An example of such a page, you can see here: Factsheet | bit by bit Software Coaching… Of course the table data are placed by hand…

@TonHaarmans ,
well, csv Import itself should be relativ easy, as already stated.
doing this automatically is, however, a different story :smiley: .
but, luckily, Grav has already a built-in functionality for doing things automatically in a predefined time schedule: the Grav Scheduler.
I think it should be possible to use this for your task, which would, to my understanding, imply to 1. export the data from the access DB to a csv file and 2. import this csv to dedicated grav pages.
btw. I am currently working on a grav plugin that creates ics calendar files from remote caldav calendars via the scheduler: caldav2ics - maybe this can help you getting started.

Another option: Use Drupal 8

Why Drupal:

  • Grav is a flat-file CMS…
  • Drupal has a build-in database API with ample documentation
  • The current website of the client is build in Drupal.
  • Does the client have a compelling reason to destroy their current investment (build costs, time, knowledge, experience, etc.) in Drupal and move to an entire new CMS?
  • Data:
    • The current website shows a list of at least 87 courses.
    • I presume (and hope) the Access database has been laid out normalised which means:
      • multiple tables are involved, eg. a ‘course’ table and ‘schedule’ table
    • The page that lists all courses needs a subset (columns) of data from the ‘courses’ table.
    • Each page showing details and schedule of a course requires its own subset of the ‘course’ table (row and columns) and a subset (row/columns) of the ‘schedule’ table.
    • Passed scheduled dates will probably need to be removed from the resulting dataset.
    • As far as I can tell, the Table Importer plugin does not provide filtering of the imported csv data file.
    • Considering the above, a single csv dump will not suffice.
      Every page needs its own subset of the data from Access. Which means a dedicated export for each page (87 at least).
    • How robust and manageable will this be?

In my opinion, the data requirements would be better served using direct database access with proper SQL queries that can dynamically select subsets (of rows and columns) of the database per page.

  • No recurring exporting process needed
  • Always up-to-date data in front-end
  • Front-end page will probably be easier to build and maintain

Does Grav provide a proper plugin to fulfill the data requirements or will it become a makeshift solution to force Grav into the project?

Unfortunately, from what I know about the client and project, I cannot give the final answers…

1 Like

Yes, that’s another option. Why I do not, at the moment, choose for Drupal is the following:

  1. The existing site is in Drupal 7. The whole site needs to be redesigned to work with Drupal 8. The site needs anyway to be redesigned, then why not with Grav.
  2. The data which need to be updated regularly are only the dates and places of the courses. I have already worked out a way to do this with CSV. The central access database can export the data for each course and place them on /user/data folder. In every page that need to have this data I can work with the table importer plugin. Works like a charm. CSS does the rest.
  3. The Admin interface of Grav is A LOT LESS intimidating then the one of Drupal…
  4. I also have to work with it and I like Grav a lot more then Drupal.
  5. The page that lists all courses is something I need to look at. It now relies heavily on the Drupal Views plugin and jQuery. Right now, that’s the only page I worry about to do in Grav. Columns is no problem.
  6. Maintaining and updating the drupal sites is a real PITA…