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

Static routes configuration #19

Open
impossiblecode opened this issue Feb 14, 2015 · 1 comment
Open

Static routes configuration #19

impossiblecode opened this issue Feb 14, 2015 · 1 comment

Comments

@impossiblecode
Copy link

Let me go ahead and apologize if I am failing to understand an obvious method to solve this problem, but I really could not find a way yet.

Let us imagine that for a particular set of pages, I want to create a route using segment_1 that maps to a template with a different url_title than the one that is present at that channel's entry without issuing a redirect.

Example: 'example.com/privacy' (maps to) 'example.com/static/main/privacy-policy'

In this example, the "group/template" would be "static/main" and the real url_title, would be "privacy-policy".

What I am looking to do is replace some of the routes I have using Freeway, now that the project has been discontinued.

@rsanchez
Copy link
Owner

Here's what I suggest:

$config['resource_router'] = array(
    'privacy' => function($router) {
        $router->setGlobal('page_url_title', 'privacy-policy');
        $router->setTemplate('static/main');
    },
);

This will route /privacy to the static/main template, and set a {page_url_title} global template variable set to privacy-policy.

Then, you'd update your static/main template, to use the {page_url_title} variable:

{exp:channel:entries channel="my_pages" dynamic="no" url_title="{page_url_title}" require_entry="yes"}

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

2 participants