1

I've created a custom HTML tag that pulls information from my database and displays it. Basically it uses preg_match_all to parse the body of articles for <profiletag>Person Name</profiletag> and replaces this tag with html of the person's profile.

Now what I want is to allow my writers to insert this HTML (<profiletag>Person Name</profiletag>) from the WYSIWYG editor rather than having to go into the source and insert a tag into the html. When they write <profiletag> etc. in the WYSIWYG editor obviously it gets all messed up. I'm looking for something like [profile]Person Name[/profile] markup for them to include these tags in the WYSIWYG side.

Is this possible, and if so how can I implement this functionality?

1

What you need is a custom filter. Filters are the check boxes you can set on input formats like 'Filtered HTML' and 'Full HTML'.

There is an example available in the examples module: https://www.drupal.org/project/examples

Basically, you need this:

1) You need to implement hook_filter_info() to let Drupal know there is a new filter 2) You need to a function to process the input. This is where you can use your regex.

I highly suggest looking at the examples module or any other modules that use filters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.