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 6137181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:41:38+00:00 2026-05-23T17:41:38+00:00

I am trying to include a small code in each page of my site.

  • 0

I am trying to include a small code in each page of my site.
Is there any way to do this without modifying each controller?

For example – I want to read/unread message from Message model.

Can i do this using the app_controller? I have add following function in app_controller.php.
I need suggestion. Please help me.

function messageStatus() {
    App::import('Model','Message');
    $new_message = $this->Message->find(
    'first',
            array (
                'conditions' => array (
                    'Message.status' => '1'
                )
            )
        );
    $this->set("new_message",$new_message); 
}
  • 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-23T17:41:39+00:00Added an answer on May 23, 2026 at 5:41 pm

    Depending on when you want to execute your actions, you will have to override in the app_controller.php file one of the following functions (according to the documentation), :

    beforeFilter()
    afterFilter()
    beforeRender()
    

    Since all your other controllers will be inheriting the methods of this class, your actions will be executed every time (as specified in the docs) one of your controllers are executed.

    If you want to have a controller that does not run the code in the app_controller simply override the method again locally.

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

Sidebar

Related Questions

I'm trying to build a really simple php controller page for a small site.
Im trying to make a small app in c++ that saves midifiles with this
I have a Php page the code for which is below, I am trying
I have a small code snippet that I'm trying to get to work in
I'm trying to write a small piece of code that merges lines alternatively from
I am trying to make a small thread example. I want to have a
I am trying to include a small image as a separator in my menu
I've been trying to parallelize this piece of code for about two days and
I've got a small bit of code that I'm trying to execute via an
I am trying to find any examples on how to code jquery mobile swipe

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.