SIngle Page Controller Redirect

Permalink
Hi,

I've a single page structured like that :

/controller/profile/demo/controller.php
/controller/profile/demo/search.php


I would like to redirectwww.www.mywebsite.com/profile/demo/... towww.www.mywebsite.com/profile/demo/search/...

To do that I have this code inside demo/controller.php

<?php defined('C5_EXECUTE') or die("Access Denied.");
class ProfileDemoController extends Controller {
   public function on_start() {
      $this->redirect('/profile/demo/search');
   }
}


But redirection does not work...

The single page are correctly registered throught the dashboard > single pages.

Thanks
moosh

moosh
 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
You can write down the code in demo/controller.php like this:

class ProfileDemoController extends Controller {
   public function __construct() { 
      $this->redirect('/profile/demo/search');   
   }   
}


Hope this helps!

Rony
moosh replied on at Permalink Reply
moosh
Thank you, but it does not work
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I'm not sure what happen there, but I've used the same piece of code many times in different packages. It works perfectly there.
Maybe the problem is somewhere else. Try to debug it by the die statement in your controller and check whether it shows anything.

Rony
moosh replied on at Permalink Best Answer Reply
moosh
After creating a view.php single page and refresh this single page in Dashboard > Single page, it work...

So, a view.php file is required.

Thank you for your help

moosh
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Ahhh! you didn't have view for controller. You should have it always to render.

Rony