[ckan-dev] How to provide a different home page, from an extension?

David Read david.read at hackneyworkshop.com
Wed Aug 16 14:05:44 UTC 2017


Jenny,

You are on the right track.

I've overridden routes in the past by deleting them - see
https://github.com/ckan/ckan/pull/2674/files . You can probably just
paste the delete_routes_by_name function definition into your
plugin.py and call it in your before_map function:

    delete_routes_by_name(map, 'home')

Just be aware that that approach may not work with future CKAN
versions because CKAN will move to Flask-based controllers with
Flask-controlled url routing. But for the time-being it should be
fine.

Regards,
David

On 31 July 2017 at 20:56, Jenny Brown <jenny.brown at climate.com> wrote:
> I'd like to replace the default home page (layout1 with 4 boxes) with custom
> content that includes data not provided by the default controller code.  I'd
> prefer to do this from my extension rather than changing ckan core source.
>
> At a high level, what are the steps I need to follow to do this?
>
> My guesses:
> * implement IRoutes, override the route for the home page to go to my
> controller
> * implement my controller and use it for data lookup
> * provide my web template that uses the new data
>
> I'm struggling a little to understand exactly how to override the route for
> the home page... so I want to make sure I'm at least chasing the right
> strategy.  I've overridden templates for styling before but this is my first
> time trying to replace a controller.
>
> Thanks.
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list