I have been working on a project but i have hit a snag with custom routes and parameters.
My code is as follows:
Only HOME and Page return a k_matched_route the rest fail. The link returns nothing. May be it is because i am trying to populate the parameters dynamically from a different template. The links invoking the view are as follows:
HOME:
template-1.php
----------------
pretty url should return-(www.localhost.com/template)
PAGE: (template-1.php page view)
<cms:route_link 'page' rt_page_name=k_page_name />">
---------------
pretty url should return-(www.localhost.com/template/page-name.html)
FOLDER: (template-1.php folder view)
<cms:route_link 'folder' rt_folder_name=k_page_foldername />">
---------------
pretty url should return-(www.localhost.com/template/foldername)
PARAMETER: (template-1php page and folder view but with additional page and folder variables from template-2.php) - from template-2.php i fetch custom_field from pages and use it to pupulate the page_name and Folder_name variables then send them with route_link to template-1, thus:
<cms:route_link 'parameter' rt_page_name=k_page_foldername />">
where k_page_foldername is now template 2's folder name and k_page_name is now template 2's page name.
---------------
pretty url should return-(www.localhost.com/template/page-name-page-name.html) and or
---------------
pretty url should return-(www.localhost.com/template/folder-page-name.html)
++++++++++++
Kindly assist me with a cleaner simpler way of doing this as i have yet to master custom routes.
As always i appreciate your help.
My code is as follows:
- Code: Select all
.....
<cms:route name='home' path='' />
<cms:route name='page' path='{:page_name}' filters='page_exists=name'>
<cms:route_validators
page_name='title_ready' />
<cms:route_validators
id='non_zero_integer' />
</cms:route>
<cms:route name='folder' path='{:folder_name}' filters='page_exists=name'>
<cms:route_validators
page_name='title_ready' />
<cms:route_validators
id='non_zero_integer' />
</cms:route>
<cms:route name='parameters' path='{:folder_name} {:page_name}' filters='page_exists=name'>
<cms:route_validators
page_name='title_ready' />
<cms:route_validators
id='non_zero_integer'/>
</cms:route>
</cms:template>
<cms:match_route debug='1' is_404='1' />
<cms:if k_matched_route='page' >
<cms:embed 'page' />
<cms:else_if k_matched_route='folder' />
<cms:embed 'folder' />
<cms:else_if k_matched_route='home' />
<cms:embed 'default' />
<cms:else_if k_matched_route='parameters' />
<cms:embed 'parameters' />
</cms:if>
Only HOME and Page return a k_matched_route the rest fail. The link returns nothing. May be it is because i am trying to populate the parameters dynamically from a different template. The links invoking the view are as follows:
HOME:
template-1.php
----------------
pretty url should return-(www.localhost.com/template)
PAGE: (template-1.php page view)
<cms:route_link 'page' rt_page_name=k_page_name />">
---------------
pretty url should return-(www.localhost.com/template/page-name.html)
FOLDER: (template-1.php folder view)
<cms:route_link 'folder' rt_folder_name=k_page_foldername />">
---------------
pretty url should return-(www.localhost.com/template/foldername)
PARAMETER: (template-1php page and folder view but with additional page and folder variables from template-2.php) - from template-2.php i fetch custom_field from pages and use it to pupulate the page_name and Folder_name variables then send them with route_link to template-1, thus:
<cms:route_link 'parameter' rt_page_name=k_page_foldername />">
where k_page_foldername is now template 2's folder name and k_page_name is now template 2's page name.
---------------
pretty url should return-(www.localhost.com/template/page-name-page-name.html) and or
---------------
pretty url should return-(www.localhost.com/template/folder-page-name.html)
++++++++++++
Kindly assist me with a cleaner simpler way of doing this as i have yet to master custom routes.
As always i appreciate your help.