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

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

eZ debug

Timing: Jan 31 2025 00:19:06
Script start
Timing: Jan 31 2025 00:19:06
Module start 'layout'
Timing: Jan 31 2025 00:19:06
Module start 'content'
Timing: Jan 31 2025 00:19:07
Module end 'content'
Timing: Jan 31 2025 00:19:07
Script end

Main resources:

Total runtime1.2760 sec
Peak memory usage8,192.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.2656151.2266
Module start 'layout' 0.00450.0037 739.4922220.7188
Module start 'content' 0.00821.2668 960.21094,581.4063
Module end 'content' 1.27500.0009 5,541.617219.8125
Script end 1.2759  5,561.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2642160.0002
Check MTime0.00120.0944160.0001
Mysql Total
Database connection0.00060.046210.0006
Mysqli_queries1.167791.5178740.0158
Looping result0.00080.0619720.0000
Template Total1.225896.120.6129
Template load0.00180.139020.0009
Template processing1.224095.927020.6120
Template load and register function0.00170.131510.0017
states
state_id_array0.00110.088210.0011
state_identifier_array0.00200.159620.0010
Override
Cache load0.00170.1297510.0000
Sytem overhead
Fetch class attribute can translate value0.00160.127740.0004
Fetch class attribute name0.00220.1742100.0002
XML
Image XML parsing0.00150.121140.0004
class_abstraction
Instantiating content class attribute0.00000.0018110.0000
General
dbfile0.00340.2668280.0001
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs