Dynamic cms with php js ajax, reusable segments - design thoughts?

Sorry long post/thought train - grab a coffee first :slight_smile:

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:

  1. The user requests a page name. e.g. index.php?page=register

  2. 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.

  3. 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.

  4. 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:

  1. 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.

  2. 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.

  3. 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.

Issues:

  1. 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?

  2. 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
    strings.

  3. 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.

Thank you!

Not really new. It is a large project however. I was on a team that built a portal like that for companies. Donā€™t go from scratch, use a framework. It will make your life easier.

what framework would you suggest that allows me to use what i want without having to eat the whole horse and deal with extra stuff i dont want in my project? i am currently researching webkit, ghost and october cms, but im more interested to code my own if i can.

On the surface, it looks like a huge project, but i think i can start small, and get the page builder and ajax working. no themeing, no user logins, no css etc.
Then add in those as it starts to work - so i guess im asking to see what you seasoned coders can see are possible issues and what work-arounds /solutions would be make things easier?

Use what you want and incorporate libraries when needed.

It IS a huge project. As someone that has done it, it is a lot of work.

You should always start small, but there is a lot of planning that needs to be done and ways things should be written to allow for changes and modifications later.

Follow SOLID principles to make things a little easier.

Thanks mate, iā€™ll keep those in mind.
The end result is to have a cms that any lay user can administer themselves without coding, like redcap (research web app), but much functional with custom js ajax functions.
I have seen symfony and laravel etc, but im not that great of a coder in terms of the schema and principles as of yet., i tend to enjoy hacking code from scratch.

Do one of the ā€œno-framework, frameworkā€ tutorials.

I tried writing a framework solo based on the handful of framework features I knew I needed and I limited to only the small handful I felt I could write and maintain by myself.

8 years later I still havenā€™t finished making my pagination code work properly with my base model code among a hundred other unfinished things.

Sponsor our Newsletter | Privacy Policy | Terms of Service