My current customer is aiming for a closed text-viewer, while keeping certain variables open for customers. This is to show a preview of the text, while not relying on the client side for the whole text. At the moment, I think of a form, which contains input elements. These elements will dynamically be filled into certain spans in the text so the client is able to see the preview. When the form is submitted, the server side will replace the identifiers with the inputs.
My current idea is to let my client create a text which contains identifiers, which the client can fill in or show with checkboxes. All these elements are stored in a mysql database, which can result in something like this:
You are thinking about %el1%, and you want to create %el2%. %bl3%
This is using the following inputs.
<input type="text" name="el1">
<input type="text" name="el2">
<input type="checkbox" name="bl3">
To replace these identifiers with A) elements which can be changed by Javascript and B) can be replaced by PHP in the full document.
You are thinking about <span id="el1"></span>, and you want to create <span id="el2"></span>. <span id="bl3" style="display:none;">This is a text that is retrieved from the database, and shown when the user checks the checkbox</span>
I don't know if this is a good idea at all, but the client wishes it to be this way. In this way, the client can't edit the full text, but only input certain inputs. I will validate these both client- and serverside.
Is this a good idea? If no, what should I do instead? And if yes, how can I create a loop that will find these identifiers based on %el1% or %bl3% and replace these with <span>
tags or the submitted variables?