• I’m developing a WP MVC based project currently.

    I’d really like to be able to use pretty URLs that don’t include the ID… something like

    https://<hostname>/performers/roy-janik

    rather than

    https://<hostname>/performers/65/roy-janik

    I have a route defined as
    MvcRouter::public_connect(‘performers/{:name:[a-zA-Z]+-[a-zA-Z]+}.*’, array(‘controller’ => ‘performers’, ‘action’ => ‘show’));

    So far I haven’t had any luck.

    If I throw debugging statements into the core, I can see that at some point name is indeed getting set to roy-janik, but the time the show() method of the performers controller is getting called, the params array is empty.

    Is there a way to do what I want, or do you always have to have the id in the URL?

    https://www.ads-software.com/extend/plugins/wp-mvc/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author tombenner

    (@tombenner)

    Hi,

    Thanks for letting me know about this; there was indeed a bug here, but it has been fixed in 1.1.2, which I’ve just pushed out. The passing of the params in above route should work as expected now, but if it doesn’t, definitely just let me know.

    If there’s anything else that you happen to catch, don’t hesitate to shoot me a line.

    Best,
    Tom

    Thread Starter royjanik

    (@royjanik)

    Awesome! Thanks so much.

    Hi, love this framework!!! Thank you very much.

    I have been trying to implement pretty urls as shown here: https://wpmvc.org/documentation/65/pretty-urls/

    with no success.

    I have added:

    function to_url($yachts) {
    $slug = $yachts->yacht->yachtName;
    $slug = preg_replace(‘/[^\w]/’, ‘-‘, $slug);
    $slug = preg_replace(‘/[-]+/’, ‘-‘, $slug);
    $slug = strtolower($slug);
    return ‘yachts/’.$yachts->yacht->yachtId.’/’.$slug.’/’;
    }

    To the Model.

    And
    MvcRouter::public_connect(‘yachts/{:id:[\d]+}.*’, array(‘controller’ => ‘yachts’, ‘action’ => ‘show’));

    to routes. What am I missing???

    $yachts is a simplexml object.

    Thanks in advance!!!
    German

    Any idea where to start????

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP MVC] pretty URLs’ is closed to new replies.