Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:12:55+00:00 2026-05-27T01:12:55+00:00

I have a function in a controller that first checks a to see did

  • 0

I have a function in a controller that first checks a to see did the user submit a form from the website, facebook or mobile.

It then changes the layout as needed. But with mobile I want to load a different view as the display is quite different.

My problem is that the data from the controller is not getting passed to the new view. I get undefined variables and arguments for all the php within the view. The php code is exactly the same in all views, it is only the layout of the div’s I am changing in the mobile view.

I cannot see why this might be happening?

Controller

function availability() {

    if ($_REQUEST['from'] == 'facebook') {
        $this->layout = 'facebook';
    }elseif ($_REQUEST['from'] == 'website'){
        $this->layout = 'res';
    }elseif ($_REQUEST['from'] == 'mobile'){
        $this->layout = 'mobile_layout';
        $this->render( 'mobile' );
    };

    $this->newSession();

    $msg[0] = array(); // 0 = bad messages
    $msg[1] = array(); // 1 = good messages 

    if(isset($_REQUEST['date_start'],$_REQUEST['date_end'])){
            $data['Availability']['date_start'] = $_REQUEST['date_start'];
            $data['Availability']['date_end'] = $_REQUEST['date_end'];
    }

    if(!isset($_REQUEST['voucher_code'])){
        $_REQUEST['voucher_code'] = 0;
    }   

One of the errors within the mobile view, line 83 in the res_controller is $this->render( ‘mobile’ );:

 Notice (8): Undefined variable: availability [APP/views/res/mobile.ctp, line 16]
Code | Context

include - APP/views/res/mobile.ctp, line 16
View::_render() - CORE/cake/libs/view/view.php, line 731
View::render() - CORE/cake/libs/view/view.php, line 426
Controller::render() - CORE/cake/libs/controller/controller.php, line 909
ResController::availability() - APP/controllers/res_controller.php, line 83
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:12:56+00:00Added an answer on May 27, 2026 at 1:12 am

    When you call Controller::render, I believe the view is rendered (and returned) immediately. So, before that call you have to set any variables the view is expecting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function on my controller (Im using CodeIgniter) that reads the database,
I have a function that pulls data from two locations and places the returned
I have persistent login in my website so if user checks the remember me
I have a simple unsubscribe function in my Unsubscribed controller. if ($this->Unsubscribe->save($this->data['Unsubscribes'])) { //
I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:=Id)> <ModelBinder(GetType(CustomModelBinder))> ByVal object As
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have function getCartItems in cart.js and I want to call that function in
I have a button click function that is to run a $.getJSON when the
I have something like public class Controller { [Observer(fetchEmployeesEvent)] public function fetchEmployees() : void
How do you put two different function outputs from the same controller into the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.