Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to take advantage of CKAN's main navigation menu, it gets a little tricky. (We just had to figure this out. Not sure if we did it the right way, but we did get it to work with CKAN 2.2):</p> <p>First, you need the additional content in your extension path somewhere. Assuming it's at <code>my_extension/amazing.html</code>, you want to add the following to the <b>my_extension/templates/header.html</b> file (in your custom extension):</p> <pre><code>{% ckan_extends %} {% block header_site_navitagtion_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')), ('group_index', _('Groups')), ('about', _('About')), ('amazing', _('Amazing Extension')) ) }} {% endblock %} </code></pre> <p>This will cause a server error, since "amazing" hasn't been registered in pylons as a mapped route. We'll fix that next. If you've built your extension properly, you should have a <b>my_extension/plugins.py</b>, to which you'll need to add the following to your plugin's class definition:</p> <pre><code>class AmazingPlugin(plugins.SingletonPlugin, tk.DefaultDatasetForm): #or plugins.implements(plugins.IRoutes, inherit=True) def before_map(self, m): m.connect('amazing', #name of path route '/amazing', #url to map path to controller='ckanext.my_extension.controller:AmazingController', #controller action='amazing') #controller action (method) return m </code></pre> <p>..where <code>ckanext.my_extension.controller</code> is the include path to <b>my_extension/controller.py</b>, which we'll create next. It should consist of:</p> <pre><code>import ckan.plugins as p from ckan.lib.base import BaseController class AmazingController(BaseController): def amazing(self): return p.toolkit.render('amazing.html') </code></pre> <p>That's it. Now you've got a controller mapping a url to a nav item that you can call with <code>h.build_nav_main()</code>. Simple, right? ;) One last thing. You'll need to restart apache for it to take effect.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload