Forums / Developer / How to embed a module output on a frontpage?

How to embed a module output on a frontpage?

Author Message

Maria Cheung

Monday 23 November 2009 2:54:16 am

Hi all, I have created my own extension and modules. I can view the modules fine, by going to their URL. However, now I want to embed them on a page, much like a content class. How do I go about doing that?

 

Thanks!

Niko Goers

Monday 23 November 2009 3:52:58 am

Hi Maria,

in the site.ini you can find the lines:

[SiteSettings]
IndexPage=/content/view/full/2/

I think it should be possible to overrides this with your own module:

[SiteSettings]
IndexPage=/yourmodule/yourview/

IndexPage doc

Please tell me the result.

Good luck

Edit: Hum, you don't want to replace your frontpage, right? Then my way is wrong. What's the task of your module? I need some more information.

eZ Publish partner - http://www.all2e.com
http://share.ez.no/directory/companies/all2e-gmbh
http://ez.no/Partners/all2e-GmbH

Lords of Heaven - http://www.LoH-Gilde.de (Created with eZ Publish)
German online gaming guild

About me - http://www.NikoGoers.de

My roadmap, +1 are welcome: http://share.ez.no/community/roadmap/10889

Maria Cheung

Monday 23 November 2009 4:32:48 am

No, I want to be able to embed the module within my frontpage. I think I have found a way though.

I created the extension and module and also a template operator, which calls a function which does all the functionality (for instance, showing my twitter feed). I created a content class and overrode the template for it. In the new template, I used the template operator to call my module functionality. Then I embedded the new content class on the frontpage. Voila!

I'm sure there is an easier way to do this, but I couldn't find it. Thanks for your reply.

Gaetano Giunta

Monday 23 November 2009 5:30:49 am

What you have done is not very far from the minimum amount of work required.

The way I would have organized it:

- some php class or function that calculates the stuff you need

- a template to show it

- a new module/view that binds those 2 things together

for the homepage, you could have:

- create a tpl operator (or even better a fetch function) encapsulating the new business logic; no need for a class override/new class, just override the template for full view of node 2; in the overridden tpl call your new operator and include your new template

- instead of adding your 'block' directly to the homepage template, added a new attribute, eg. of type "string" to the homepage. Then use a datatype override template to inject the calls to the new tpl operator + inclusion of new tpl. This way you could have eg. put the twitter feed ID as value of the new attribute

Principal Consultant International Business
Member of the Community Project Board

Niko Goers

Monday 23 November 2009 5:45:02 am

Hi,

yes thats one way it works. But it would be nicer to use a template function instead of a template operator.

That is the correct und easiest way I think.

Greetings

Edit: Gaetano was faster :)

eZ Publish partner - http://www.all2e.com
http://share.ez.no/directory/companies/all2e-gmbh
http://ez.no/Partners/all2e-GmbH

Lords of Heaven - http://www.LoH-Gilde.de (Created with eZ Publish)
German online gaming guild

About me - http://www.NikoGoers.de

My roadmap, +1 are welcome: http://share.ez.no/community/roadmap/10889

Maria Cheung

Monday 23 November 2009 6:12:23 am

Thanks for the replies guys. The reason I created a new content class is so the CMS user who is not techie, can add the module in various places via the admin backend. If there's a better way to do it than a content class, let me know, I'm still a EZ newbie :)

Thanks again :)

Bertrand Dunogier

Monday 23 November 2009 6:50:26 am

If you're using eZ Flow, you could create a custom block... :)

Another option would be a custom XML tag, with attributes that are used as parameters.

In both cases, you can use what you wrote for your module (operator) in the matching custom templates to display your custom module's data.

Regarding access to this data, the most logical approach would have been a template fetch functions, since their role is to... well, there's no better way to put it: fetch.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

eZ debug

Timing: Jan 18 2025 10:23:46
Script start
Timing: Jan 18 2025 10:23:46
Module start 'content'
Timing: Jan 18 2025 10:23:47
Module end 'content'
Timing: Jan 18 2025 10:23:47
Script end

Main resources:

Total runtime1.4983 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.9609180.8125
Module start 'content' 0.00641.3311 769.7734679.0391
Module end 'content' 1.33750.1607 1,448.8125341.0547
Script end 1.4982  1,789.8672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.2800210.0002
Check MTime0.00160.1081210.0001
Mysql Total
Database connection0.00080.050310.0008
Mysqli_queries1.389492.73002110.0066
Looping result0.00240.15852090.0000
Template Total1.467297.920.7336
Template load0.00200.135420.0010
Template processing1.465297.788620.7326
Template load and register function0.00020.014810.0002
states
state_id_array0.00100.068610.0010
state_identifier_array0.00160.107520.0008
Override
Cache load0.00160.1094510.0000
Sytem overhead
Fetch class attribute can translate value0.00220.148850.0004
Fetch class attribute name0.00130.0894100.0001
XML
Image XML parsing0.00740.493550.0015
class_abstraction
Instantiating content class attribute0.00000.0015110.0000
General
dbfile0.00830.5541390.0002
String conversion0.00000.000430.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
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs