Html Editor "safe Ranges"


I need to provide a simple HTML editor, so the end-user may edit a page content easily.

But the trick is:

The page code is prepared by a professional designer who should be able to compose it in such a way, that only certain areas are editable while the rest of page code remains locked aginst the end-user.

So, you may think about it as in case of Dreamweaver template - only code between

tags should be accessible for the end-user.

Any idea how to attack this problem in a clever way?

Thanks ahead!

Hi ziggi

Even If you achieve that by javascript (locking the no editable texts) you will have security issues.

So, you have to make parts of html on view file and the a editable part related by a model field.

If I not understood very well, please post more details

Hi KonApaz!

I would rather avoid client-side solutions.

I think about a following workflow in controller:

  1. Load a model

  2. Trace editable and non-editable regions regions with appropriate algorithm

  3. Render them part by part in a view form using:

    <input type="textarea">echo $this->editableData</textarea> for editable regions and

    <div>echo $this->nonEditableData</div> in case of non editable regions

  4. Apply WYSWIG editor instances to all ‘textareas’ with javascript.

  5. While saving data with WYSWIG editor - pass them through controller, substitute appropriate regions in model data with submitted ones and save the updated model.

Does it sound reasonable or you have some objections? Please share your opinion!

Yes its a good solution

So, the best way to do that is the below

1)render all no-editable texts (without any rules in model)

2)render all(or one) editable texts (with model rules) and code in controller that calls the save methos of the model.

3)you can use a WYSIWYG editor for all editable-texts