Sorry long post/thought train - grab a coffee first
I am wanting to build a dynamic CMS using PHP, Ajax and MySql that
has re-usable data block divs - explained below.
Im thinking this web app would have hundreds of data blocks over time (text label,
boxes with ajax dropdowns and some simple js functions, inside a div - see attached pic)
and so would like to use the php-include function to dynamically build pages
and re-use pre-coded html/js made data block segments (code chucks
saved in files), that have functioning ajax and js when fully rendered.
The overall system design would be as following - index.php:
The user requests a page name. e.g. index.php?page=register
A page-builder php function would get the data block element NAMES
from the Database (e.g for ‘register’ page) and then dynamically php-include
the pre-coded divs/js/ajax code chunks as separate divs, that will load the data elements for the requested page, one div after the next.
Each pre-coded div would have functioning js and ajax scripts of their own along with the html elements. Once php has generated the whole page, the page readys all the ajax /js scripts and the final html elements renders.
The user can then interact with any of the divs (e.g Date of
Birth data block, user inputs text, and ajax validates and saves to DB,
on some event) - each div uses ajax to save input and/or return
displaying data, populates its dropdown list, etc. kind of like a webpage made of lots of little iframes.
The user requests another page… Repeat step 2 and so on.
Initially just handling text data, image links but may later add charts and
graphs, data grids and more complex data types and plugins.
The benefits, I assume would be that:
once a data field segment is coded (html div, js scripts, ajax, php
ajax partner functions), it can be re-used on any other page or shared.
Php can handle the server side ajax functions and each div data field would manage its own saves and data retrievals. the php file used to store the chuck of codes can be updated and
managed with ease, being its own separate file. you would have 1 file
per data fields, so 1000s of small files for 1000s of different data fields.
Superusers/ Admins would just edit the database regarding what data fields names should be on what page, create new pages, etc. new data blocks would have to be coded if required.
The pre-coded segemnts would be messy and complex, js might not fully work
after being loaded by ajax? extra/other ajax functions inside the div itself
might also not work?
might be hard to manage branching and logic when working with
multiple data blocks/ divs. e.g The user enters date of birth as
01-01-1995 and so the next data block question auto disables, greys out because it
is not required for those born after 1990. I assume a js script in the Header, that can
handle these basic functions globally by accepting id names and optional text
speed of loading pages and lots of ajaxing…?
I guess this would be a smaller drupal like cms framework without all the junk i dont need… but still be very custom.
Any thoughts on issues, design flaws or general advice?
I dont want to use drupal or any blogger wordpress framework, I would like to build my own custom framework.