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

  • Home
  • SEARCH
  • 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 8585687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:07:43+00:00 2026-06-11T22:07:43+00:00

I am having problems with trying to set global variables with my CakePHP 2.2.2

  • 0

I am having problems with trying to set global variables with my CakePHP 2.2.2 app. I have defined the following inside my AppController :

 App::uses('Controller', 'Controller');

 class AppController extends Controller {

  function beforeFilter() {

   $MenuTest = "MENU TEST";
   $this->set('Menu', $MenuTest);

  } //End of beforeFilter()
}

This is meant to set $MenuTest as a global variable right? So I should be able to access $MenuTest on any controller or view I want? An less I am missing something?

App::uses('AppController', 'Controller');

class PagesController extends AppController {

public $name = 'Pages';
public $uses = array();

 public function display() {
    debug( $Menu);
    die();
    $this->render('home');
 }//End of function display()

 function test () {
    echo $Menu;
    echo 'This is testing a new link';
    die();
 }//End of function test()
}

When I load my page, all that debug gives me is a ‘null’. Again the same when I use the test function?

Please help? What I am doing wrong?

Thanks, Glenn

  • 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-06-11T22:07:44+00:00Added an answer on June 11, 2026 at 10:07 pm

    Controller::set() sets a view var, not a class var. If you want a class var inherited by all sub-classes you would do $this->Menu = 'Some value'; and access with $this->Menu.

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

Sidebar

Related Questions

I am having problems trying to do the following. I am trying to incorporate
I'm trying to figure this out and having problems. I have several projects (not
I'm having some minor problems with some animations I'm trying to set up. I
I'm trying to set up a websocket server in node.js but having problems. I
I've been having some problems while trying to fix a simple video recording app*.
I am having problems of trying to set a session cookie(s) in Liferay 6.0
Im having problems with trying to set a select option to selected, it does
I am having a javascript problem. What I am trying to do is set
I'm having problems trying to make a reactive form. When I insert data into
I am having problems trying to load libpng in my native android project. It

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.