Forum
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
Are you generating two slugs at once with the for=""? Is that possible? It isn't in the docs...
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?
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.
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!
Hey, no probs at all. I wonder if this issue is resolved in Perch 3.
That depends if you're using transliteration or not. Did you check?
I have checked and Transliteration is enabled so that’s not the issue.
Does perch not strip + symbols from slugs?
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.
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.
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.