Database to page routing API?

Question

Lets say I have in my database a table for Universities – and for each entry in the database, the primary key would be the name of the University, i.e Duke.

If I created a template for all the university pages i.e university-template, is it possible to have an automatic routing to the specific universities page ( university-template updated with data from the database )?

i.e when someone accesses www.website.com/university/Duke the university-template is populated with the Duke entry from the database table. If the entry (in above examble, university/{slug}, slug is the entry to be searched) is not stored in the table then send the user to different custom template like uni-not-found-error-template.

Or do I need to create a page for each university ( like this question )

My current idea is to write a custom API that functions like so:
User sends GET request: GET www.website.com/university/Duke
University Table is queried for slug: Duke
If value error: send user to custom error page
If valid: pull template and fill corresponding Duke data from table
Display to page to User.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/database-to-page-routing-api/">

Database to page routing API?</a>
0
, , , Adam Kit 2 months 0 Answers 53 views 0

Leave an answer