This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

floriskoch
floriskoch

I'm using the builder plugin to show overview and detail pages. The structure is very simple, it's just an overview page with url: products, and a detail page with url products/:slug.

This works fine as long as I use existing products, with existing URLs. However when I enter something random as the slug it still goes to the page but just displays nothing. I would like it to redirect to the 404 page to give the user a nicer experience. I could add something like this to the template of every detail page but that seems very ugly and I don't want to add so much logic to my templates.

function onEnd()
{
    if (!$this['builderDetails']->record) {
        $this->setStatusCode(404);
        return $this->controller->run('404');
    }
}

Is there any built-in behaviour like this in the Builder plugin? Or is there another nicer way to achieve this?

balazs.buda35618
balazs.buda35618

Foris, did you find a solution to the problem in the last 2 years?

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.