Make a Lasting Impression

Join the Mailing List

Who's Online

15 user(s) are online (3 user(s) are browsing ImpressCMS Blog)

Members: 0
Guests: 15

more...
ImpressCMS proudly uses SourceForge
ImpressCMS on Ohloh.net
ImpressCMS Blog > Getting Out of the Box - Textsanitizer Plugins for ImpressCMS

Getting Out of the Box - Textsanitizer Plugins for ImpressCMS

Off the shelf applications don't always do what you want them to do, so usually, a little customization is in order. For some applications, it is like wading through the bayou as you look through their code to find the right spot to make your change. Other projects have their stuff in order and you're surprised at how easy it is to modify and extend what they've packaged up for you. ImpressCMS is definitely falling into the second category!

After using hashtags and mentions on Twitter and Facebook, I thought 'This would be a cool little addition to ImpressCMS!' So, I started out to create plugins to allow me to use these common tags.

Extending the ImpressCMS Textsanitizer

It's fair to say I've spent more than a little time in the code of ImpressCMS, but with a little research and some help in the forums, just about anyone who can understand just a little PHP and with the right tools can create a plugin (or even a module) for ImpressCMS.

What tools do you need?

A text editor. And, if you're not a regular expressions wizard, an regex tool, like the Regular Expressions Tester extension for Firefox. If you want to test this locally, you'll need to set up a web server, like XAMPP, to run and install your site.

Where do you go next?

If you look through the administration area of ImpressCMS, you'll find a Plugins Manager under Preferences. On closer examination, you'll see several plugins already listed - hiddencontent, syntaxhighlightercss, syntaxhighlighterjs, syntaxhighlighterhtml and several others - now you just need to find the code for those plugins. A quick file search will lead you to /your-root-path/plugins/textsanitizer/ - every plugin listed as a corresponding folder here. So, it makes sense our new plugin will go here, too. Using these files as a pattern for our new plugin, it was very easy to create a plugin for using hashtags in posts.

The following video will take you through the complete process, step by step. I also talk about some of the coding standards we use and 'Convention Over Configuration' - a practice that makes programming easier for everyone. The video is 25 minutes long and rather than chop it up so it all fit on YouTube, I left it complete and uploaded it to blip.tv - you can watch it there. Creating a textsanitizer plugin for ImpressCMS

Coding Standards

Along the way, it's always good to share some other information about the code behind ImpressCMS. Here are a few resources that give you a look into our standards and practices, with a few optimization tweaks thrown in.

- http://wiki.impresscms.org/index.ph ... _Standards

Make It Go Faster series -
- http://community.impresscms.org/mod ... ost_id=146
- http://community.impresscms.org/mod ... ost_id=147
- http://community.impresscms.org/mod ... ost_id=148
- http://community.impresscms.org/mod ... ost_id=159
- http://community.impresscms.org/mod ... ost_id=162

Once you see how easy it is to customize ImpressCMS without having to hack a bunch of files that will be overwritten with your next upgrade, you'll find all sorts of things to add - you'll be hooked!

All posts by skenow
Subscribe to latest posts
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
david
Posted: 2010/6/11 8:07  Updated: 2010/6/11 8:07
Home away from home
Joined: 2008/2/12
From:
Posts: 1491
 Re: Getting Out of the Box - Textsanitizer Plugins for Im...
Very useful indeed!

How tricky would it be to replace the #[xxxx] tag for a #xxx tag? I guess the brackets are used if you need to use mutiple words?
skenow
Posted: 2010/6/11 12:00  Updated: 2010/6/11 12:01
Home away from home
Joined: 2007/12/4
From:
Posts: 4106
 Re: Getting Out of the Box - Textsanitizer Plugins for Im...
rather simple to remove the [ and ], but then you wouldn't be able to to multiple words or phrases and you might get confused with a numbering system or numbered list.

Watch the section on the regex and you'll see what to modify there and hashtags.js will also need to be adjusted, but it is pointed out in the video

Also not taken into consideration is the minimum number of characters set in the search preferences
skenow
Posted: 2013/11/23 21:56  Updated: 2013/11/23 21:56
Home away from home
Joined: 2007/12/4
From:
Posts: 4106
 Re: Getting Out of the Box - Textsanitizer Plugins for Im...
Blip.tv has scrubbed a bunch of videos, including this one. Luckily, YouTube has extended their recording limits and I have uploaded the video there.
sato-san
Posted: 2013/12/4 0:44  Updated: 2013/12/4 2:58
Home away from home
Joined: 2007/12/4
From: /home/日本
Posts: 1768
 Re: Getting Out of the Box - Textsanitizer Plugins for Im...
Steve, this is a great video!

It's possible to share the created files also? I want to share on our download section in the community page.

Edit: Does the plugin (for example #hashtag) works in the TinyMCE also?
skenow
Posted: 2013/12/7 21:33  Updated: 2013/12/7 21:33
Home away from home
Joined: 2007/12/4
From:
Posts: 4106
 Re: Getting Out of the Box - Textsanitizer Plugins for Im...
Yes, Rene, the plugins work for any editor, there just won't be a button added to the toolbars for any of the wysiwyg editors. Both the hashtag and mention plugin are the the 2.0 branch in the Git repository.