Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pages URLs incorrect if a non default language selected #16

Open
rpietzsch opened this issue Nov 11, 2014 · 3 comments
Open

pages URLs incorrect if a non default language selected #16

rpietzsch opened this issue Nov 11, 2014 · 3 comments
Assignees

Comments

@rpietzsch
Copy link

Steps to reproduce:

  1. install and enable ckanext-pages
  2. Explicitly select a language from the ckan footer
  3. login a sysadmin and add a page --> 404

Please advise if this is a configuration issue. Currently we consider this a bug.

Thanks, René

@dvenance
Copy link

dvenance commented Mar 4, 2015

Hi,
i had a same problem here, and the problem was the page creation form that was appending double language code when i try to access the page after creating it, for example 'en' language your page will have URL: opendata.go.xx/en/pages/ in the page creation form if you look well, so this is where the problem is because after creating it when you try to access it while you have switched the the language the URL that appear will be like opendata.go.xx/en/en/pages/

Note: repeatation of en in the URL

Soln,
i edited ckanext-pages/ckanext/pages/theme/templates_main/ckanext_pages/base_form.html

so that i trim language in the URL, by changing:

{% if type == 'org' %}
  {% set action_url = h.url_for('organization_pages_edit', id=id, page='/' + page)|replace("sw/", "")|replace("en/", "") %}
  {% set cancel_url = h.url_for('organization_pages', id=id, page='')|replace("sw/", "")|replace("en/", "") %}
  {% set slug_prefix = cancel_url ~ '/' %}
  {% set slug_domain = h.url_for('organization_pages', id=id, page='', qualified=true) %}
  {% set hide_field_order = true %}
{% elif type == 'group' %}
  {% set action_url = h.url_for('group_pages_edit', id=id, page='/' + page)|replace("sw/", "")|replace("en/", "") %}
  {% set cancel_url = h.url_for('group_pages', id=id, page='')|replace("sw/", "")|replace("en/", "") %}
  {% set slug_prefix = cancel_url ~ '/' %}
  {% set slug_domain = h.url_for('group_pages', id=id, page='', qualified=true) %}
  {% set hide_field_order = true %}
{% else %}
  {% set action_url = h.url_for('pages_edit', page='/' + page)|replace("sw/", "")|replace("en/", "") %}
  {% set cancel_url = h.url_for('pages_show', page='') |replace("sw/", "")|replace("en/", "") %}
  {% set slug_prefix = cancel_url ~ '/' %}
  {% set slug_domain = h.url_for('pages_show', page='', qualified=true) %}
{% endif %}

{% set data = data or {} %}
{% set errors = errors or {} %}

{% if not page %}
  <h1>{{ _('Add page') }}</h1>
{% else %}
  <h1>{{ _('Edit page') }}</h1>
{% endif %}

<form class="form-horizontal" method="post" action="{{ action_url }}" data-module="basic-form">

  {{ form.input('title', id='field-title', label=_('Title (en)'), placeholder=_('eg. Page Title'), value=data.title, error=errors.title, classes=['control-full', 'control-large'], attrs={'data-module': 'slug-preview-target'}) }}

  {{ form.input('title_sw', id='field-title_sw', label=_('Title (sw)'), placeholder=_('eg. Kichwa cha Ukurasa'), value=data.title_sw, error=errors.title_sw, classes=['control-full', 'control-large'], attrs={'data-module': 'slug-preview-target'}) }}

  {% set domain = slug_domain|replace("http://", "")|replace("https://", "")|replace("sw/", "")|replace("en/", "") %}
  {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain~'/', 'data-module-placeholder': '<page>'} %}
  {{ form.prepend('name', id='field-name', label=_('URL'), prepend=slug_prefix, placeholder=_('eg. my-page'), value=data.name, error=errors.name, attrs=attrs) }}

  {#{{ form.input('name', id='field-name', label=_('Name'), placeholder=_('my-name'), value=data.name, error=errors.name, classes=['control-full']) }}#}

  <div class="control-group">
    <label for="field-private" class="control-label">{{ _('Visibility') }}</label>
    <div class="controls">
      <select id="field-private" name="private">
        {% for option in [(true, _('Private')), (false, _('Public'))] %}
        <option value="{{ option[0] }}" {% if option[0] == data.private %}selected="selected"{% endif %}>{{ option[1] }}</option>
        {% endfor %}
      </select>
    </div>
  </div>

Note:
|replace("sw/", "")|replace("en/", "")

which ommit en and sw, in this case can your languages,

@manuelpalacin
Copy link

Hi,
I have installed pages extension with CKAN 2.3. I tried to create a new page with the plugin but it throws and error after clicking the "Add" button. I do not know what is happening because with the CKAN 2.2 it works nice. Do you know any solution to this bug?

Thanks!

@joetsoi
Copy link
Contributor

joetsoi commented Apr 14, 2015

ah ok, confirmed that this is a problem, @Venochloride I'll take a look to see if your fix is of any help

@joetsoi joetsoi self-assigned this Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants