Ad

RealURL With GET Parameters

- 1 answer

We have developed a typo3 plug in that searches for trucks. For SEO reasons, we are trying to use the realURL plug in to make the URLs friendlier to use.

On the front page we have several call to actions that link to the search page with certain search parameters. An example is bellow:

/search-results/?tx_fds_searchresults[type_name]=Trailer

This link works as expected. On the results page is a link to the listings page with more details. An example is bellow:

/listing/?tx_fds_listing[id]=119870

This link is not working. tx_fds_listing[id] is not being populated in the arguments passed to the plug in controller.

At first we thought it might be a config issue but again, it isn't present on other pages. The ID is not a database object and may be a text string instead.

Edit:

I should add that it works fine with RealURL turned off.

We get the id as $id = $this->request->getArgument('id');

Edit 2: Here is the error message from the logs. [ALERT] request="28233e225150a" component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": Oops, an error occurred! Code: 201512141630381db91bba - {"exception":"exception 'TYPO3\\CMS\\Extbase\\Mvc\\Exception\\NoSuchArgumentException' with message 'An argument \"id\" does not exist for this request.'

I also tried renaming the variable to name, but that didn't work either.

Ad

Answer

I have a solution that solves the root cause of the problem, if not the specific issue.

So I had to add additional mapping to the realurl_conf.php file. For example to get the listing id:

$config['domain.com']['postVarSets'][3]['stock'] = array(array('GETvar' => 'tx_fds_listing[id]'));

This makes the effective URL:

/listing/stock/119870

This was the intended usage for the plugin, so this is a good result. I also added configuration for ajax and pdfs. This required modification to the typoscript that was not obvious.

PDF TS:

pdf = PAGE
pdf {
    typeNum = 300
    10 = USER_INT
    10 {
        userFunc      = TYPO3\CMS\Extbase\Core\Bootstrap->run
        #vendorName    = TYPO3
        extensionName = Fds
        pluginName = Listing

        #controller = FDS
        controller = Tx_Fds_Controller_FDSController
        #action = listingPdf
        switchableControllerActions.FDS.1 = listingPdf


    }
    config {
        disableAllHeaderCode = 1
        additionalHeaders = Content-type:application/pdf
        xhtml_cleaning = 0
        admPanel = 0
    }
}

PDF RealURL Config:

$config['domain.com']['postVarSets'][3]['pdf'] = array('type' => 'single', 'keyValues' => array ('type' => 300));

PDF effective URL:

/listing/pdf/stock/119870
Ad
source: stackoverflow.com
Ad