1

I'm trying to create custom URL's with the route manager.

{route='products/overview' series='series' range='range' prod='{url_title}'}

in my template named 'overview' I have three products that have been entered and they're linked to via the route path above. The correct URL does get generated but only one entry is shown for each of the pages, for example:

http://www.mysite.com/products/series/range/my_product_1

will show 'my_product_1' for each of the products even if the URL is

http://www.mysite.com/products/series/range/my_product_2

or

http://www.mysite.com/products/series/range/my_product_3

Any help is very much appreciated.

EDIT

I've attached some screenshots of the issue to aid help

route manager Template code

The two screenshots above shoe the route manager and template with the route path

The two below are the web pages that are showing the correct URL's and the correct template but the same entry for each page. Just two examples but on the three entries I have set up one entry is shown on all pages.

screen 1 screen 2

{exp:channel:entries channel="product_range" limit="1"}
{embed="embeds/docHead" my_page_title="{title} | Pico Technology"}
<body>
<!-- Static navbar -->
<header class="navbar navbar-default navbar-static-top head-wrap">
{embed="embeds/headNav" myLocation="prod"}
<!-- main body -->
<div class="wrapper body-wrap">
    <div class="container main">
        <a href="/" class="navbar-brand"></a>
        <div class="row">
            <div class="col 12 col-sm-12 col-lg-12">
                <ul class="breadcrumb">
                    <li><a href="/">Home</a></li>
                    <li><a href="/products">Products</a></li>
                    <li><a href="/products/oscilloscopes">Oscilloscopes</a></li>
                    <li><a href="/products/oscilloscopes">PicoScope 2000 Series</a></li>
                    <li class="active">{title}</li> 
                </ul>
            </div>
        </div>  
        <!-- ABOVE CODE IS GENERIC TO EVERY SUBPAGE -->
        <div class="row">
            <div class="col-xs-12 col-sm-4 col-md-4 leftCol">
                {range_left}
                {left_copy}
                <img class="img-responsive" src="{left_image}" alt="{exp:assets:files}{alt_text}{/exp:assets:files}">
                {/range_left}
                {embed="option_panels/{price_option_panel}"}
            </div>
            <div class="col-xs-12 col-sm-8 col-md-8 mainContent">
                <ul class="nav nav-tabs" id="myTab">
                    <li class="active"><a href="{url_title}">Overview</a></li>
                    <li><a href="{url_title}-features">Features</a></li>
                    <li><a href="{url_title}-specifications">Specifications</a></li>
                    <li><a href="{url_title}-software">Software</a></li>
                    <li><a href="{url_title}-documents">Manuals</a></li>
                    <li><a href="{url_title}-accessories">Accessories</a></li>
                </ul>
                <div class="tab-content">
                    {overview}
                        <div class="prod-feat-mod">
    {if whatsinthebox != ''}<div class="well pull-right whatsinthebox">
                                {whatsinthebox}
                            </div>{/if}
                            {prod_image}{if lightbox == 'y'}<a class="imgRight zoom fancybox" href="{url}"><img class="img-polaroid img-responsive" src="{url}" alt="{alt_text}" title="{title}"></a>{if:else}<img class="img-polaroid img-responsive imgRight" src="{url}" alt="{alt_text}" title="{title}">{/if}{/prod_image}
                            {prod_copy}
                        </div>
                    {/overview}
                </div>
            </div>
        </div>
    <!-- BELOW CODE TO JAVASCRIPT IS GENERIC TO EVERY SUBPAGE -->   
    </div>
</div>
<a href="#" class="scrollup">Scroll</a> 
<!-- footer -->
<div class="wrapper foot-wrap">
    <footer>

        {embed="embeds/footerPanels"}
        {embed="embeds/footer"}

    </footer>
</div>

<!-- ABOVE FOOTER CODE IS GENERIC TO EVERY SUBPAGE -->

<script type="text/javascript" charset="utf-8" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" charset="utf-8" src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>  
<script type="text/javascript" charset="utf-8" src="{path='javascript/{price_option_panel}'}"></script> 
<script type="text/javascript" charset="utf-8" src="{path='javascript/xdr'}"></script> 
</body>
</html>
{/exp:channel:entries}
  • I'm not really familiar with how the routing manager works but have you specified a dynamic="off" parameter in your entries tag? – foamcow May 13 '14 at 10:22
  • Can you please include a sample of your template so we could have more information? – Johnathan Waters May 13 '14 at 15:57
  • Can you, please, add the route of the template? – Robson Sobral May 13 '14 at 17:35
  • My route is:/products/{series}/{range}/{prod:alpha_dash} – Jonathan Green May 14 '14 at 10:28
  • dynamic="off" has been set but still not working – Jonathan Green May 14 '14 at 10:31
3

Now I can help you.

The exp:channel:entries module just looks dynamically for an entry if its title appears on segment_2 or segment_3. For your template, it appears on segment_4. Buuuuuuuuuuut template routes overrides this behavior. From the docs:

Template Routes overrides the default behavior of URLs, if you wish to use a Channel Entries Tag in your template you must manually provide segments for any parameters that are normally set in the URL. You must provide a segment for pagination, categories, and entry titles if you wish to use those in your Channel Entries Tag. Additionally, be careful when using dynamic=”yes” with Template Routes, this can cause issues if your route does not have an appropriate segment set.

To make it work, set the url_title parameter of the exp:channel:entries and make it not dynamic.

So, on the template used for a single entry, products/osc-overview in your case, replace:

{exp:channel:entries channel="product_range" limit="1"}

By:

{exp:channel:entries channel="product_range" limit="1" dynamic="no" url_title="{segment_4}" require_entry="yes"}

I added the require_entry="yes" to allow you to use no_results conditional.

The route segment still needs a name. For example, on the current routes setting, the forth segment is being called "alpha_dash", what should be its rule:

/products/oscilloscopes/picoscope2000/{alpha_dash}

So, add its name and use alpha_dash as a rule:

/products/oscilloscopes/picoscope2000/{prod:alpha_dash}

Now, the prod segment can be accessed on the exp:channel:entries module variable by its right name:

{exp:channel:entries channel="product_range" limit="1" dynamic="no" url_title="{segment:prod}" require_entry="yes"}

You can use this logic for your other pages.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.