ckan / ckanext-pages

A simple builtin CMS for CKAN sites
GNU General Public License v3.0
51 stars 99 forks source link

Fix, add ckan.root_path to ckanext/pages/plugin.py #102

Open Patrick1Rhode opened 4 years ago

Patrick1Rhode commented 4 years ago

This fixes the handling of the ckan.root_path = {name} reported here #98.

amercader commented 3 years ago

@Patrick1Rhode @ccancellieri Can you try if this alternative approach works for you:

diff --git a/ckanext/pages/plugin/__init__.py b/ckanext/pages/plugin/__init__.py
index e688a38..9aad086 100644
--- a/ckanext/pages/plugin/__init__.py
+++ b/ckanext/pages/plugin/__init__.py
@@ -78,7 +78,8 @@ def build_pages_nav_main(*args):
         else:
             name = quote(page['name'])
         title = html_escape(page['title'])
-        link = tk.h.literal(u'<a href="/{}/{}">{}</a>'.format(type_, name, title))
+        url = tk.url_for('pages.{}_show'.format(type_), page=name)
+        link = tk.h.literal(u'<a href="{}">{}</a>'.format(url, title))
         if page['name'] == page_name:
             li = tk.literal('<li class="active">') + link + tk.literal('</li>')
         else:

Also please keep the .gitignore file