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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:07:10+00:00 2026-05-13T16:07:10+00:00

Sorry about the question title, but I couldn’t find a more appropriate way to

  • 0

Sorry about the question title, but I couldn’t find a more appropriate way to phrase this.

I am currently building a CakePHP powered website and I’m not quite sure how to approach the following issue. The website looks something like the follwing mockup:

Website Mockup
.

The greyed out areas are part of the layout, because their content does not change between views. In the sidebar, I have a collection of ads who are linked to several models. I need controller logic to determine the picture associated with an ad. Also, the ad list needs to be dynamic. Where should I put the logic for building the sidebar?

I’ve thought about:

  • putting the logic into the AppController (beforeFilter / afterFilter) – the problem is I can’t use the controller logic I need (the other controllers inherit from AppController, I’m not sure how to use them there).
  • making a component – is it okay to build components that rely on controllers?
  • replicating the sidebar code in all controllers that render views – this seems kind of stupid to me.

What is the Cake way for this?


Update

After some reading and experimenting, I’ve gotten to refactoring most of it.

I obtained the best performance by moving the logic for building my ads in the model (eliminating the component that retrieved the pictures) and not using requestAction. It’s almost three times faster and the code looks much better.

  • 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-13T16:07:11+00:00Added an answer on May 13, 2026 at 4:07 pm

    I’ve done something similar for data-driven navigation. I put my logic in AppController::beforeRender and haven’t had any problems. I’m not sure I understand your concern related to controller inheritance. I retrieve my menus via:

    $menus = $this->NavMenuItem->groupByMenu();
    $this->set( compact( 'menus' ) );
    

    I then created an element that renders the menu. It’s executed by the layout via:

    <?php echo $this->element( 'navigation', array( 'id' => 'secondary', 'menu' => $menus['SECONDARY'] ) ) ?>
    

    If that doesn’t help, maybe you can further explain your issue with controller inheritance in a comment.

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

Sidebar

Related Questions

Sorry about the title to this question, it's not very clear but wasn't sure
Sorry, couldn't find a more appropriate title. In My code I have two classes
Sorry about the vague title, but i didnt know how to ask the question
First, sorry about the title of this question. I thought about it for a
Sorry about the weird question title, but I don't really know what to call
First, I am sorry about the bad title, but after 5 minutes I couldn't
Sorry about the title, I couldn't come up with a clean way to ask
This is not the clearest of question titles, sorry about that, but I will
First, sorry for the vague question title. I couldn't come up with a more
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>

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.