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