Forums / Developer / the simplest extension

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

eZ debug

Timing: Jan 19 2025 15:25:28
Script start
Timing: Jan 19 2025 15:25:28
Module start 'content'
Timing: Jan 19 2025 15:25:29
Module end 'content'
Timing: Jan 19 2025 15:25:29
Script end

Main resources:

Total runtime0.7633 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.9297180.8438
Module start 'content' 0.00510.6601 769.7734542.8281
Module end 'content' 0.66520.0980 1,312.6016332.7734
Script end 0.7632  1,645.3750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4867210.0002
Check MTime0.00150.1924210.0001
Mysql Total
Database connection0.00050.069410.0005
Mysqli_queries0.700791.80321940.0036
Looping result0.00150.19611920.0000
Template Total0.739696.920.3698
Template load0.00200.259320.0010
Template processing0.737796.642020.3688
Template load and register function0.00020.025110.0002
states
state_id_array0.00070.097510.0007
state_identifier_array0.00120.154320.0006
Override
Cache load0.00160.2157370.0000
Sytem overhead
Fetch class attribute can translate value0.00120.154130.0004
Fetch class attribute name0.00150.202840.0004
XML
Image XML parsing0.00080.108530.0003
class_abstraction
Instantiating content class attribute0.00000.001740.0000
General
dbfile0.00480.6259270.0002
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs