Forums / Developer / How to extend kernel classes and module's views ?

How to extend kernel classes and module's views ?

Author Message

H-Works Agency

Tuesday 28 August 2007 6:31:53 am

Hi all,

Is it possible to extend a kernel class in a custom extension ? For exemple ezOrder ?

I tried to create such an extension by making a "class myOrder extend ezOrder {}". It works of course but i can't add my view to the ezShop module.

I tried to add my new view to viewList() array but its not taken into consideration.

It would be great if we could extend a core class inside a module and to be able to add new views to this module without having to write down a new module with custom class.

This is the same topic as being able to override kernel functions (without going through the "php_include_path" technique).

This would be a great help by allowing us to make small changes, or to correct wrong behavior in kernel functions without having to modify ezp sources or to wait futur releases.

EZP is Great

Piotrek Karaś

Wednesday 07 November 2007 11:09:02 am

Isn't eZ Publish 4 supposed to provide such functionality (to override kernel classes)? Can anyone elaborate on that subject?

(...)

Here we go:
<i>Kernel classes may be overridden by classes in extensions, due to the new autoload regime (making kernel modifications mostly unnecessary), however this flexibility should be exercised with caution.</i>
http://ez.no/developer/news/ez_publish_4_0

Time to try ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

André R.

Wednesday 07 November 2007 12:47:27 pm

Yes it is currently possible to override core classes in eZ Publish 4 with the autoload system, but it's not a intentional feature so might change in the future.

Could you elaborate on what you need it for? (bugs / missing features...)

Overriding classes is of course not recommended in the long run since your override classes could break stuff in a future version and you need to closely watch any changes that are made to those classes each time you update/upgrade.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Piotrek Karaś

Wednesday 07 November 2007 1:43:12 pm

That's interesting, the way it was described during the partner meeting - I got an impression that it was a goal that was going to be achieved ;)

Yes, I do see the possible risks, even though I suspect that override system is always provides little bit of safety and flexibility more than direct modification of critical files. Since I don't know how it works exactly at this point, I cannot assess it and tell you whether I will find it useful in the future or not. Maybe once I've played with it a bit in the next days.

I'm mostly thinking of altering some of the system core functions and options. eZ Publish is quite well written and it's very tempting to make use of it ;) The other thing is that I still may not see all the direct and elegant solutions. One of such things: http://ez.no/developer/forum/general/poll_unique_vote_options_summary_and_questions

Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

H-Works Agency

Wednesday 15 June 2011 6:19:21 am

Hello,

Is it possible to add/override a new view to a kernel module ?

Three simple examples/questions :

- You take the built-in "shop" module and you want to add a "reservation" view to it, how would you proceed ?

- Still in that module the built-in "basket" view doesn't suit your needs, how to override it ?

For now to resolve those problems i have to create a whole new module which is long, boring and conceptually not very satisfying.

Thanx in advance.

EZP is Great

Gaetano Giunta

Wednesday 15 June 2011 7:07:58 am

To add a view to an existing module, you could create the view in a custom module then add a virtual-url rule to make your custom view belong in the original module. One drawback: you cannot declare in module.php for module B that a view depends on an access function defined in module A. To do so, you'll have to do explicit perm checking within the view code.

Using url rewrites, you can also "take control" of existing views. Another way to reach the same goal is to change settings in site.ini so that your extension's modules/views are scanned before the kernel ones (but be careful with that)

Principal Consultant International Business
Member of the Community Project Board

eZ debug

Timing: Jan 29 2025 13:43:53
Script start
Timing: Jan 29 2025 13:43:53
Module start 'content'
Timing: Jan 29 2025 13:43:53
Module end 'content'
Timing: Jan 29 2025 13:43:53
Script end

Main resources:

Total runtime0.1444 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.0625180.8125
Module start 'content' 0.00730.0045 768.8750101.9297
Module end 'content' 0.01170.1326 870.8047530.6250
Script end 0.1444  1,401.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.3987200.0002
Check MTime0.00130.8786200.0001
Mysql Total
Database connection0.00161.079510.0016
Mysqli_queries0.097667.57611410.0007
Looping result0.00120.84971390.0000
Template Total0.132391.610.1323
Template load0.00070.516610.0007
Template processing0.131591.084310.1315
Override
Cache load0.00050.371810.0005
Sytem overhead
Fetch class attribute can translate value0.00060.390610.0006
XML
Image XML parsing0.00020.165410.0002
General
dbfile0.00664.5784200.0003
String conversion0.00000.003630.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs