Jump to content

$page->getView() doesn't return a value


Recommended Posts

Posted

Hi @teppo!

I' trying to check what view file the user is on but the getView method returns null. 

I'm using it like this in the controller (tried both in the render and init method):   

if($this->wire('page')->name == "kopa-bil"){
        $this->view->setView('buy');
    }

And

$page->getView()

in the view-file which returns null.

Posted

Hey @Mats,

In this case you're setting view directly on the View object, so you should read it from there as well:

// in controller
$this->view->setView('buy');

// in view file
echo $this->getView();
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...