Frage

Ich habe die folgende routes.php Konfiguration

got
Router::connect('/:type/:slug;:id', array(
        'controller' => 'content',
        'action' => 'show',
        'type' => null,
        'slug' => null,
        'id' => null,
    ),
    array(
        'type' => '(articles|releases|answers|videos)',
        'slug' => '[a-zA-Z0-9\-]+',
        'id' => '[0-9]+',
        'pass' => array('type', 'slug', 'id'),
    ));

und ich versuche, die folgende URL zu analysieren:

/answers/effective-language-therapy-for-people;368

Und der Router wird immer mich auf den richtigen Controller & action, aber Dumping $this->params zeigt mir, dass es nicht richtig ist die Identifizierung der $id und die $slug

Array
(
    [type] => answers
    [slug] => answers
    [id] => effective-language-therapy-for-people
    [named] => Array
        (
        )

    [pass] => Array
        (
            [0] => answers
            [1] => answers
            [2] => effective-language-therapy-for-people
        )

    [controller] => content
    [action] => show
    [plugin] => 
    [url] => Array
        (
            [ext] => html
            [url] => answers/effective-language-therapy-for-people;368
        )

    [form] => Array
        (
        )
)

Also - was ist passiert? mein regex falsch ist, nähert etwas fehlt, oder was? Irgendwelche Ideen?

Hinweis: Ich habe gelesen:


UPDATE, aufgelöst und Arbeitsversion

Router::connect('/:type/:slug:splitter:id', array('controller' => 'content', 'action' => 'view',), array(
    'type' => 'articles|releases|answers|videos',
    'slug' => '[a-zA-Z0-9\-]+',
    'splitter' => '[\;\-\|]+',
    'id' => '[0-9]+',
    ));
War es hilfreich?

Lösung

Versuchen Sie:

Router::connect('/:type/:slug;:id', array(
    'controller' => 'content',
    'action' => 'show',
    'type' => null,
    'slug' => null,
    'id' => null,
),
array(
    'type' => 'articles|releases|answers|videos',
    'slug' => '[a-zA-Z0-9\-]+',
    'id' => '[0-9]+',
    'pass' => array('type', 'slug', 'id'),
));

Das Problem wurde Typen in Klammern (), die in CakePHP nicht unterstützt wird.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top