Forum

Thread tagged as: Problem

Slug is not making + URL friendly

I have a list and detail page that uses the slug

<perch:content id="slug" type="slug" for="job_title job_id" suppress="true" />

But one of the titles is "C++ Quant Strategist / Developer – Equities" and slug is not making the + URL safe, so the link results in a Page Not Found. I have tried replace="+|" but that has not worked.

What Can be done to fix this issue?

Perch: 2.8.34, PHP: 5.6.37, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, fpm-fcgi
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), form_builder (1), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'form_builder', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/millarassociates.com/httpdocs/perch
PERCH_CORE: /var/www/vhosts/millarassociates.com/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/millarassociates.com/httpdocs/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 10M, Max POST 16M, Memory: 128M, Total max file upload: 10M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: www.millarassociates.com
DOCUMENT_ROOT: /var/www/vhosts/millarassociates.com/httpdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Simon Clay

Simon Clay 127 points

  • 2 years ago

Are you generating two slugs at once with the for=""? Is that possible? It isn't in the docs...

Simon Clay

Simon Clay 127 points

Hi Shane, yes I am using it that way. It is in the docs:

https://docs.grabaperch.com/templates/field-types/slug/

'You can also use a space-separated list of IDs in the for attribute. This will draw content from multiple fields.'

Do you have transliteration enabled?

Simon Clay

Simon Clay 127 points

I have no idea Eddie, can you tell me more?

If you check the extended diagnostics report, you should be able to see if transliteration is enabled or not.

I believe its default enabled in PHP 7, but not sure about 5.6. Its also very hosting-dependent i guess.

I've had problems before with special signs and slugs related to this. If its not enabled on your server, I would look into getting it enabled, or updating the PHP version to PHP 7.

Simon Clay

Simon Clay 127 points

Thanks Eddie, I will check it out and report back.

Cool! Had no idea you could join fields for slugs. Sorry, didn’t mean to derail the thread!

Simon Clay

Simon Clay 127 points

Hey, no probs at all. I wonder if this issue is resolved in Perch 3.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That depends if you're using transliteration or not. Did you check?

Simon Clay

Simon Clay 127 points

I have checked and Transliteration is enabled so that’s not the issue.

Does perch not strip + symbols from slugs?

Diagnostics report
PERCH INFORMATION

Perch: 2.8.34
Production mode: Production (100)
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), form_builder (1), perch_forms (1.8.3)
DB driver: PDO
DB tables: perch2_categories (12), perch2_category_counts (0), perch2_category_sets (1), perch2_content_index (5999), perch2_content_items (662), perch2_content_regions (18), perch2_forms (3), perch2_forms_responses (12), perch2_navigation (1), perch2_navigation_pages (2), perch2_page_templates (4), perch2_pages (6), perch2_resource_log (261), perch2_resource_tags (140), perch2_resources (83), perch2_resources_to_tags (368), perch2_settings (22), perch2_user_passwords (0), perch2_user_privileges (29), perch2_user_role_privileges (19), perch2_user_roles (2), perch2_users (4)
Users: 4
PHPMailer: 5.2.21
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_forms',
        'form_builder',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: perchlinks, redactor, markitup
H1: 12b392482c6e12c789f4aa53f08779bb
L1: ad2a3ac9fa376c8fdfc1123292e891fe
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
headerColour: #0d0158
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.34: done
latest_version: 2.8.15
on_sale_version:
headerScheme: dark
perch_blog_site_name:
perch_blog_post_url: /blog/post.php?s={postSlug}
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_comment_notify: 0
logoPath: /perch/resources/millar-associates-logo.png
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: millar_perch
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: millar_perch
PERCH_DB_PREFIX: perch2_
PERCH_TZ: Europe/London
PERCH_EMAIL_FROM: s.clay@cstltd.com
PERCH_EMAIL_FROM_NAME: Simon Clay
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/millarassociates.com/httpdocs/perch
PERCH_CORE: /var/www/vhosts/millarassociates.com/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/millarassociates.com/httpdocs/perch/resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_RUNWAY:
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: /var/www/vhosts/millarassociates.com/httpdocs/perch/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_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 5.6.37
Zend: 2.6.0
OS: Linux
SAPI: fpm-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
MySQL server: 5.5.56-MariaDB
Free disk space: 42.67 GB
Extensions: Core, date, ereg, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, Reflection, session, standard, SimpleXML, sockets, mbstring, tokenizer, xml, cgi-fcgi, mysqlnd, bcmath, curl, dba, dom, enchant, fileinfo, gd, imagick, imap, intl, json, ldap, exif, mcrypt, mysql, mysqli, odbc, PDO, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, redis, soap, sqlite3, sysvmsg, sysvsem, sysvshm, tidy, xmlreader, xmlrpc, xmlwriter, xsl, zip, ionCube Loader, Zend OPcache
GD: Yes
ImageMagick: Yes
PHP max upload size: 10M
PHP max form post size: 16M
PHP memory limit: 128M
Total max uploadable file size: 10M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
USER: millar_admin
HOME: /var/www/vhosts/millarassociates.com
FCGI_ROLE: RESPONDER
UNIQUE_ID: W3klbpFPBUGuce1xvRMZYQAAAMc
SCRIPT_URL: /perch/core/settings/diagnostics/
SCRIPT_URI: https://www.millarassociates.com/perch/core/settings/diagnostics/
HTTPS: on
proxy-nokeepalive: 1
HTTP_HOST: www.millarassociates.com
HTTP_X_REAL_IP: 82.132.216.157
HTTP_X_ACCEL_INTERNAL: /internal-nginx-static-location
HTTP_CONNECTION: close
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_REFERER: https://www.millarassociates.com/perch/core/settings/diagnostics/
HTTP_DNT: 1
HTTP_USER_AGENT: Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1
HTTP_ACCEPT_LANGUAGE: en-gb
HTTP_ACCEPT_ENCODING: br, gzip, deflate
HTTP_COOKIE: PHPSESSID=9ptsmel29guutlm37i87hkp7s3; cmsa=1; _ga=GA1.2.50708779.1532944198; _gat=1; _gid=GA1.2.371757949.1534666039; __utma=14883882.50708779.1532944198.1532944198.1532944198.1; __utmz=14883882.1532944198.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SERVER_SOFTWARE: Apache
SERVER_NAME: www.millarassociates.com
SERVER_ADDR: 77.68.92.235
SERVER_PORT: 443
REMOTE_ADDR: 82.132.216.157
DOCUMENT_ROOT: /var/www/vhosts/millarassociates.com/httpdocs
REQUEST_SCHEME: https
CONTEXT_DOCUMENT_ROOT: /var/www/vhosts/millarassociates.com/httpdocs
SERVER_ADMIN: s.clay@cstltd.com
SCRIPT_FILENAME: /var/www/vhosts/millarassociates.com/httpdocs/perch/core/settings/diagnostics/index.php
REMOTE_PORT: 53678
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.0
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /perch/core/settings/diagnostics/?extended
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
PHP_SELF: /perch/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1534666094.9702
REQUEST_TIME: 1534666094
Drew McLellan

Drew McLellan 2638 points
Perch Support

I thought it did, but are you saying not? + is of course valid in a URL, but it represents a space.

It does at least remove it for me, but I am testing on latest version of Perch (Although I don't believe this has changed in v3). All my +'s get removed from the slug.

Do you have a local setup also, and does that act the same way? ie. WAMP/MAMP or the like.

Simon Clay

Simon Clay 127 points

Thanks, no, slug is not stripping out +

Any idea of what I can do? I know you won’t recommend editing core (this is perch 2.8.34, so won’t be updated further), but perhaps an app to extend the slug fieldtype?

Does anyone know the code that would be used to extend slug to strip + ?

Why do you mean you can't update further? V3 was a free update even with a v2 licence I believe.

I would update to the newest core and give that a try. I would also try to get the hosting server up to at least php v7.0. Both of these are good actions to take anyway.

I would definitely rather go that way, than to extend slug to strip +. As said earlier, I have tested and confirmed that +'s get stripped away on my v.3.1.2 install of perch with all default settings.

Drew McLellan

Drew McLellan 2638 points
Perch Support

This has already been address in Perch 3. The best you can do is create your own field type for slugs, or of course use the free update to Perch 3 where all this has already been done for you.