tags:

views:

45

answers:

1

Hi

I am trying to use a drop down input in my cakephp application, with this I want the drop down on submit to render the url like so:

www.example.com/cake/FILE/VALUE

However the only url i can get the select input to create is the following:

www.example.com/cake/FILE?form_value=VALUE

How do I go about making the URL SEO friendly like the first example without using httaccess because I want the URL to appear seo friendly in the search engines eyes.

Here is the code I am using.

In The VIEW

echo $form->input('form_value', array(
         'label'  => '',
         'type'  => 'select',
         'options' => $listOfOptions,
          'selected'  => '0',));

Thank you.

A: 

In your controller, get the value of "form_value" through $file = $this->data['FILE']['form_value'] and do a redirect $this->redirect(array('action' => 'download', $file)).

You then create a function called download which should look like this:

<?php
function download($file = null) {
    if ($file != null) {
        /*make download*/
    } else {
        $this->Session->setFlash('no file specified')
    }
?>

If you don't want the action "download" to appear in the URL you can use Cakes built-in routes in cakephp/app/config/routes.php.

With something like this you could map the index-action to the download-action: Router::connect('/FILE/*', array('controller' => 'files', 'action' => 'download')); See http://book.cakephp.org/view/46/Routes-Configuration for better explanation.

Tim
Ill try your method, its not exactly what i was asking but ill have to try something, also i shouldnt have used the word FILE, what i meant was CONTROLLER. e.g. cake/controller/neptune instead of cake/controller?planet_name=neptune
Stephen