Hey guys,
I’m currently developing a vehicle car site on modx cloud and I’m using an API to get the vehicle details. I have a resource (27) that uses the GET vehicleid to pull information about that particular model.
I want to generate a friendly url that converts
“myexample .com/vehicles?vehicleid=xxxxx&make=mercedes-benz&model=a-sedan”
to
“myexample .com/vehicles/mercedes-benz/a-sedan/xxxxx”
I’m seeing that CustomRequest can achieve this but I have tried multiple combinations and nothing seems to work.
Here is my setup.
Server: Ngnix (modxcloud)
In my custom request config
Configuration Name: Custom URI
Alias Path: make/model/vehicleid
Resource: Vehicles (27)
URI Parameter: [“make”, “model”, “vehicleid”]
Regular Expression: Blank
My Chunk
<a href="[[!mycustomurl?
&id=`27`
&make=`[[+dmsmake]]`
&model=`[[+dmsmodel]]`
&vehicleid=`[[+itemid]]`
]]"
title="[[+dmsmake]] [[+dmsmodel]] [[+dmsgrade]]">
</a>
My Snippet
<?php
$id = (int) $modx->getOption('id', $scriptProperties);
$make = $modx->getOption('make', $scriptProperties);
$model = $modx->getOption('model', $scriptProperties);
$vehicleid = $modx->getOption('vehicleid', $scriptProperties);
$sfl = $modx->getService('sfl_countries', 'sfl_countries', $modx->getOption('core_path') . 'components/sfl_countries/' . 'model/sfl_countries/');
if (!($sfl instanceof sfl_countries))
return '';
if ($make == "Mercedes"){
$make = "Mercedes Benz";
}
$make = $sfl->slugify($make);
$model = $sfl->slugify($model);
$url = $modx->makeUrl($id, '', array(
'make' => $make,
'model' => $model,
'vehicleid' => $vehicleid
));
return $url;
Can anyone point out what I am missing?