Search code examples
phpjavascriptlanguage-agnosticscanfcontent-management-system

How to make hard-coded HTML entries saved as if entered in the UI of a CMS?


I doubt I'm using the correct vocabulary (or tags) to explain what I'm looking for, but bear with me:

Eventually part of my page will have a section where things like list items and table data(<td>) can be entered/changed by logged in users. Let's say this is one of the <li>'s:

<!--template-->
<li><a title=""href=""><span></span></a></li>

So far my understanding is that if these entries are generated by a UI somewhere (à la Wordpress) these entries need(?) to be written in a database before becoming the generated page. Another thing I'm realizing is that the user of these CMS's doesn't automatically 'get' a copy of the generated page as source code.

What I would like to know is if it would be possible for me to make changes in HTML to this generated record/list inside notepad (I'll likely be messing with some other part of the page) and somehow have the site detect/record any changes as if they were entered through the UI?

  • Have PHP code create a file of the generated page
  • Have that page scanned for certain patterns/templates
  • Add the values found within the template to the DB, repeat

What language/approach could scan text and make database entries from its findings like how I'm describing? I just discovered sscanf(), but have no idea how to use it yet. I realize it's stupid to not just use the CMS, but the self-referential and text-scanning quality of it also interests me.


Solution

  • It sounds to me like you can implement a jQuery "Edit in Place" plug-in with a php script handler. I did something exactly this and their plug-in does all the heavy lifting, all you have to do is feed out the raw HTML with various clues about the table structure.

    See this SO q/a... I used it to generate pages that displayed orders. Via editing in place, I made the orders (click-to-edit)-able. In the code, put everything in a foreach loop, then the jQuery links elements to the database through attributes like <tr id="<? echo $database_ID ?>"> to tie a row to a record and each <td> might have the database's column name as ID or a class name.