Changes between Version 3 and Version 4 of Ticket #5452


Ignore:
Timestamp:
01/14/2019 02:49:37 PM (10 months ago)
Author:
rhowell
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5452 – Description

    v3 v4  
    77Create two global functions: 
    88 
    9 - `get_page_url(page[, locale])` that accepts a page path and locale and returns a full url based on website configuration and arguments. If locale is not provided, a link with the locale of the current page should be generated. The function should verify that the page exists in the target locale and should raise an exception if it doesn't. 
     9- `get_page_url(page[, locale, redirect=True])` that accepts a page path and locale and returns a full url based on website configuration and arguments. If locale is not provided, a link with the locale of the current page should be generated. By default, the function should verify that the page exists in the target locale and should raise an exception if it doesn't. But, if `redirect=True`, it should return the URL in the default locale. If the source has been configured to use relative links, the returned link should be relative. 
    1010- `page_has_locale(page, locale)` that accepts a page path and locale and returns `True` if the page exists in that locale and `False` if it doesn't. 
    1111 
     
    1313- The base url should be configurable in the website settings via `siteurl` variable that already exists. 
    1414- Most of the code that generates the links already exists in `cms/sources.py:Source.resolve_link`. 
    15  
    16 Questions: 
    17  
    18 - Should `get_page_url` always generate a full URL (including the hostname and port) or should it generate absolute URL without host, or something else (see also #5333)? 
    19 - Would it be useful to have a mode where `get_page_url` would generate a page in default locale if the page is absent in the requested locale instead of failing? It seems like this is what we commonly need, so not having this option at all might lead to lots of boilerplate code instead.