Forum

Thread tagged as: Problem, Runway

Slug with - not working

If you look at this url: https://vlm.so53dev.co.uk/audi-car-leasing/ and click on the A1 the Audi A1 page loads ok. The slug is a1

However, if you go back to the https://vlm.so53dev.co.uk/audi-car-leasing/ page and this time click on the A3 Sportback, the Audi A3 Sportback page doesn't load ok. The slug is a3-sportback

You can do as above again and select the Audi A4 (slug a4) and the page loads ok. So it seems to be that for whatever reason the - in the slug is causing a problem.

What am I doing wrong?

This is my model.php page:

    perch_layout('global/header');

    if (perch_get('model_slug')) {
        perch_collection('Model', [
        'filter' => 'slug',
        'template' => 'model_header.html',
        'value'  => perch_get('model_slug'),

        ]);
        }
    perch_layout('global/footer');

Neil Duddridge

Neil Duddridge 1 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can we see your Diagnostic Report please, it's a good idea to post this with each post to the forum.

Also what is set up for your Routes for this?

Hi Rachel,

Diagnostics

PERCH INFORMATION

Perch Runway: 2.8.29
Production mode: Production (100)
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_blog (5.0), perch_forms (1.8.3)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (0), perch2_blog_posts (0), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (0), perch2_category_counts (0), perch2_category_sets (1), perch2_collection_index (627), perch2_collection_items (78), perch2_collection_revisions (22), perch2_collections (2), perch2_content_index (244), perch2_content_items (32), perch2_content_regions (7), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (7), perch2_page_templates (7), perch2_pages (5), perch2_resource_log (226), perch2_resource_tags (0), perch2_resources (63), perch2_resources_to_tags (0), perch2_settings (24), perch2_user_passwords (0), perch2_user_privileges (34), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: ckeditor, markitup
H1: 514e4c76d460455a6a7b6bec32bd6c6c
L1: 95ef83c36f3f16c3f0fe678b5c0b7d01
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #da1030
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.29: done
logoPath: /site_admin/resources/website-logo.png
headerScheme: dark
update_runway_2.8.29: done
latest_version: 2.8.15
on_sale_version: 2.8.32
perch_blog_update: 5.0.1
perch_blog_post_url: /blog/post.php?s={postSlug}
perch_blog_site_name: Car Leasing Blog by Vehicle Lease Management
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 1
dashboard: 1
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_comment_notify: 0
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SCHEDULE_SECRET: sUs3TTT0rrFGz3x9
PERCH_SITEPATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev
PERCH_DB_USERNAME: root
PERCH_DB_SERVER: localhost
PERCH_DB_PORT: 8889
PERCH_DB_DATABASE: vlm_dev
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: neil@so53.co.uk
PERCH_EMAIL_FROM_NAME: Neil Duddridge
PERCH_LOGINPATH: /site_admin
PERCH_PATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin
PERCH_CORE: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core
PERCH_RESFILEPATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/assets
PERCH_RESPATH: /assets
PERCH_HTML5: 1
PERCH_TZ: Europe/London
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 7.0.10
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
MySQL server: 5.6.28
Free disk space: 90.96 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imap, gettext, mcrypt, pgsql, pdo_pgsql
GD: Yes
ImageMagick: No
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PHP_FCGI_CHILDREN: 4
PWD: /Applications/MAMP/fcgi-bin
PHP_FCGI_MAX_REQUESTS: 200
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x2
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.10.fcgi
ORIG_PATH_TRANSLATED: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /site_admin/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.10.fcgi
SCRIPT_NAME: /site_admin/core/settings/diagnostics/index.php
REQUEST_URI: /site_admin/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /site_admin/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 49189
SCRIPT_FILENAME: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev
REMOTE_ADDR: ::1
SERVER_PORT: 8888
SERVER_ADDR: ::1
SERVER_NAME: vlm.dev
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: cmssb=0; cmsa=1; PHPSESSID=f2bad1209f89e981387852d84577054c
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://vlm.dev:8888/site_admin/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: keep-alive
HTTP_HOST: vlm.dev:8888
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
FCGI_ROLE: RESPONDER
PHP_SELF: /site_admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1477361427.91
REQUEST_TIME: 1477361427
argc: 1

Routes:

See this screenshot https://www.evernote.com/l/Ai-Y9TeL42JMobTAls2Qw_Jhe6IRbLdN6Qg

Drew McLellan

Drew McLellan 2638 points
Perch Support

The slug token will capture the dashes for you. If your slugs don't include dashes, you'll need to specify a custom token.

'carslug'    => '[a-z0-9]+',

and then use

[carslug:make_slug]-[carslug:model_slug]-leasing

https://docs.grabaperch.com/runway/routing/custom-tokens/

Thanks Drew,

However, I am slightly confused (not difficult!), the slug does include dashes in my template. I have this

<perch:content id="slug" type="slug" for="model" editable="true" indelible="true" label="Slug" />

The model field contents a mix of values depending on the model entered e.g. A1, A3 Sportback, 1 Series, X5 . In the database I can see the slug is saved as a1, a3-sportback, 1-series, x5 . Screenshot of the collection item in Perch: https://www.evernote.com/l/Ai9zAe_XBrpHCJLVP-7m_Co-PnZWzqMQ_fM

Where the slug doesn't have a dash in it, the front end page loads fine. It's when the slug does have a dash in it that I run into problems. See screenshot of collection item in Perch: https://www.evernote.com/l/Ai_qfLHjgyhGWIvvWyVhz7NSiLYE3PXm-R4 - this doesn't load the collection item on the front end.

I don't understand why I would need to enter a custom token the slug generated seems ok.

I tried the custom token but that didn't work either.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What happened? What was the debug output?

Ah, I should have turned debug on!

This has given a little more insight

Good: For this https://vlm.dev:8888/audi-a1-leasing

Matched route: [slug:make_slug]-[slug:model_slug]-leasing
Using master page: /templates/pages/car.php
Page arguments:
Array
(
    [0] => /audi-a1-leasing
    [make_slug] => audi
    [1] => audi
    [model_slug] => a1
    [2] => a1
)

Bad: For this https://vlm.dev:8888/audi-a3-sportback-leasing

Matched route: [slug:make_slug]-[slug:model_slug]-leasing
Using master page: /templates/pages/car.php
Page arguments:
Array
(
    [0] => /audi-a3-sportback-leasing
    [make_slug] => audi-a3
    [1] => audi-a3
    [model_slug] => sportback
    [2] => sportback
)

I don't understand in the bad one why the make slug is audi-a3 when it should be a3 and likewise the model_slug should be a3-sportback

I should be expecting to see

Array
(
    [0] => /audi-a3-sportback-leasing
    [make_slug] => audi
    [1] => audi
    [model_slug] => a3-sportback
    [2] => a3-sportback
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

So you're still using the standard slug token? That's going to match the dashes that you do not want to match.

Use the carslug (or whatever) custom token when no dash is allowed.

Ok,

Using the custom token the following seem to now look correct

Matched route: [carslug:make_slug]-[slug:model_slug]-leasing
Using master page: /templates/pages/car.php
Page arguments:
Array
(
    [0] => /audi-a1-leasing
    [make_slug] => audi
    [1] => audi
    [model_slug] => a1
    [2] => a1
)
Matched route: [carslug:make_slug]-[slug:model_slug]-leasing
Using master page: /templates/pages/car.php
Page arguments:
Array
(
    [0] => /audi-a3-sportback-leasing
    [make_slug] => audi
    [1] => audi
    [model_slug] => a3-sportback
    [2] => a3-sportback
)

However the content isn't loading for either now

Debug says

Using template: /templates/content/model_header.html

model_header.html is

<!-- Start Page header -->
    <div class="page-header parallax" style="background-image:url(/images/header_dealer.jpg);">
        <div class="container">

            <h1 class="page-title"><perch:related id="make" collection="Make" /><img src="<perch:content type="image" id="logo" />" alt=""> <span><perch:content id="make" type="text" /></perch:related> <perch:content id="model" type="text" /></span <span class="lch"> Leasing</span></h1>
        </div>
    </div>
    <!-- Utiity Bar -->
    <div class="utility-bar">
        <div class="container">
            <div class="row">
                <div class="col-md-8 col-sm-6 col-xs-8">
                    <ol class="breadcrumb">
                        <li><a href="/">Home</a></li>
                        <li class="active"><perch:related id="make" collection="Make" /><perch:content id="make" type="text" /></perch:related> <perch:content id="model" type="text" /></li>
                    </ol>
                </div>
                <div class="col-md-4 col-sm-6 col-xs-4">
                    <ul class="utility-icons social-icons social-icons-colored">
                        <li class="facebook"><a href="#"><i class="fa fa-facebook"></i></a></li>
                        <li class="twitter"><a href="#"><i class="fa fa-twitter"></i></a></li>
                        <li class="googleplus"><a href="#"><i class="fa fa-google-plus"></i></a></li>
                        <li class="pinterest"><a href="#"><i class="fa fa-pinterest"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

Scratch that. I've sorted... I think.

Thanks for your patience.

What I needed to do was create the route using the custom token for the make_slug but leave the model_slug as it was

[carslug:make_slug]-[slug:model_slug]-leasing

I've still got a slight problem.

Where the make slug has a dash e.g. alfa-romeo I get same issue as I did with the model slug. However regardless as to how I configure the route I can't find a solution. In the end I just put a route in as 'alfa-romeo-[slug:model_slug]-leasing' which has the desired effect but not ideal as it's not dynamic and would need the client to create additional routes for other double barrelled makes (Mercedes-Benz etc.) as and when they add them.

I will keep trying things out but any other suggestions would be gratefully received

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't think this is a Runway issue as such. You need to decide on the URL format you need that will still enable you to correctly identify the parts of the path that you need to extract. It sounds like what you're currently thinking of isn't predictable enough to reliably match across all circumstances.

Ok, that's fine Drew and I agree. So long as I know, saves me going round the houses!

There aren't too many double barrelled makes anyhow so I can manually insert specific routes during the site setup.

Thanks again.