views:

201

answers:

1

Hi all,

I want to provide my users with the ability to edit blocks of content on the sites I've designed for them.

Most blocks are contained in a <div>, and the users can have free choice of the HTML they use inside the block. However, there are some blocks which are contained in, for example, <ul> tags, and I want to limit the users to only adding or removing <li>s from the list to follow correct HTML syntax.

I plan to retrieve the HTML from the database and present it to the admin user in a WYSIWYG editor. Is there any editor which will allow me to specify the 'containing tag' of a block, and follow normal HTML syntax rules to limit what can be added inside the block?

For reference, I'm using Zend Framework and PHP for the app.

+1  A: 

TinyMCE by MoxieCode is a WYSIWYG editor that allows you to initialize an instance of the editor with a list of valid tags and attributes that you would like to allow.

So, one option, you could initialize the editor differently depending on the parent element of the content that is being edited. It puts some of the work on you in terms of deciding what tags are valid in the given context, but it gives you a lot of power over the results.

An example of this is here

NerdFury
Thanks. I've looked into TinyMCE in the past and was a bit overwhelmed by the configuration possibilities. However, it looks as if I should be able to use the valid_elements option to limit what my users can post. There's also a jQuery plugin, which makes life even easier!Cheers!
George Crawford