[ckan-dev] Direct Link to an Organization
Adrià Mercader
adria.mercader at okfn.org
Mon Aug 18 09:05:39 UTC 2014
Hi Jessica,
You can hardcode the link directly or use the url function:
h.url(controller='organization', action='read', id'='abcorganization')
Neither of these will check if the org exists before, if you need this
to happen you should probably create a custom helper function that
does it:
# your_helpers.py
def org_exists(org_name):
try:
p.toolkit.get_action('organization_show')({}, {'id': org_name})
return True
except p.toolkit.ObjectNotFound:
return False
# header.html
{% if h.org_exists('abcorganization') %}
// Add link
{% endif %}
Hope this helps,
Adrià
On 15 August 2014 00:12, Jessica Good <jessica.good at azgs.az.gov> wrote:
> I want to create a "shortcut" link in the page headers to a specific
> organization page, like myckansite.com/organization/abcorganization.
> Seems like it should be easy to do but having trouble with the whole
> controller construct. What's the best way to do this? Right now I'm
> just assuming that abcorganization actually exists but will probably
> need to ensure that somehow. Thanks!
>
>
> Jessica Good
> GIS Specialist & Developer
> Arizona Geological Survey
> http://www.azgs.az.gov/
> jessica.good at azgs.az.gov
> _______________________________________________
> 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