the simplest extension

Author Message

Federico Maggi

Saturday 08 April 2006 5:03:24 am

Hi,

<b>The situation</b>
I am playing with the extension system. I need to add a new

<b>wash('textism')</b>

so I thought to override the original

lib/eztemplate/classes/eztemplatestringoperator.php

with a new

extension/washtextism/lib/eztemplate/classes/eztemplatestringoperator.php

that has a patched version of the <b>switch</b> within

function wash(...)

.

Here is the patch (diff original new):

402a403,419
>             
>             case 'textism':
>             {
>               $patterns = array('/\_([^\_]+)\_/', '/\*([^\*]+)\*/', '/\^([^\^]+)\^/', '/\~([^\~]+)\~/');
>               $replacements = array('<em>\1</em>', '<strong>\1</strong>', '<sup>\1</sup>', '<sub>\1</sub>');
>               ksort($patterns);
>               ksort($replacements);
>               $operatorValue = preg_replace( $patterns,
>                                                                          $replacements,
>                                                                          htmlspecialchars( $operatorValue )
>                                                                       );
>             } break;
>             
>             case 'strip':
>             {
>               $operatorValue = striptags( $operatorValue );
>             } break;

<b>The problem</b>
The override of the .php file is no consideret, at all, by the system. I am sure it works by itself since I tried it in the original file for debug purposes, only.

Suggestions?

Matthew Carroll

Saturday 08 April 2006 1:27:06 pm

I don't think this is the right way to go about this. You can't override the core kernel php files in an extension. The best way to achieve what you're trying to do would be to create a new template operator, say mywash, build that into an extension, and then use it in your templates. There is a wizard to help you waiting (hidden!) in your admin site, e.g...

http://example.com/admin/setup/templateoperator

See also the old documentation:

http://ez.no/products/ez_publish/documentation/development/kernel/custom_template_operators
http://ez.no/products/ez_publish/documentation/development/extensions/template_operator

Good luck!

Matthew

http://carroll.org.uk

Federico Maggi

Sunday 09 April 2006 4:09:10 am

Thank you and thanks to #ezpublish on freenode, too.

I have found that great RAD template operator wizard and in about 15 mins I had my template operator extension ready and published! Cool!

Here you can find the extension

http://ez.no/community/contribs/template_plugins/eztextism

please let me know about bugs or possible improvements.

Regards,

--

Federico http://www.maggi.cc

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.