Hello,
I am trying to develop a custom homepage for my website but I cannot manage to make it work the way I want.
I would like to display some backend information (events, for example) so I made a controller that gets all that data and makes a render_template afterwards.
My problem is that I can't find a way to call it "directly". My homepage url is like this : http://localhost:8069, so I don't know how to define the @http.route option for my controller.
I tried with an ajax.jsonrpc call, and it works, but I then I cannot edit a part of the template because it crashes. My code was like this :
homepage/xml :
<template id="homepage_template" inherit_id="website.homepage">
<xpath expr="//div[@id='wrap']" position="inside">
<div id="events"/>
</xpath>
</template>
<template id="wdi_homepage_data">
event infos here
</template>
And my controller looks like this :
@http.route('/homepage/', methods=['POST'], type='json', auth="public", website=True)
def load_data(self, **kw):
events = request.env['event.event'].search([('date_begin', '>', fields.Date.today())], limit=4)
return request.env['ir.ui.view'].render_template("my_module.homepage_template", {
'event': events,
})
Can someone explain me how to make a proper template for the website homepage ?
Thanks a lot !