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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:01:16+00:00 2026-06-13T03:01:16+00:00

I’m working on a webapp based on CakePHP 2.2. I created some plugins that

  • 0

I’m working on a webapp based on CakePHP 2.2. I created some plugins that fit into the main application. In the main application I have an dynamic menu. Now I want the plugin to show op in this menu.

I think, the best way is to let the plugin register its menu items in the main application. Then the main application builds the menu (using a helper). But I’m not sure how to do this. Is it possible to let a plugin interact with the main application even when its AppController is isn’t touched? I want to show up all the plugins, not only the current plugins action.

  • 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-13T03:01:18+00:00Added an answer on June 13, 2026 at 3:01 am

    It depends on your implementation details. In general you should see a plugin really as a plugin. So your application can use it if available. So concept code for example:

    if(pluginAvailable('PagesPlugin')) {
      $this->set('menu', $this->PagesPluginComponent->getMenuItems());
    }
    

    You application can depend on it but it can also not be here. That’s the generic concept of a plugin. In real world it’s much harder because you cannot show your webpage without the menu so that creates a real dependency.

    A plugin should be re-usable.

    Some options:

    Fully plugin based page structure

    You create a plugin which has the table pages in itself. The plugin has a component which loads the menu items and a helper which supports showing them.

    So in your appcontroller load the component, here you set the dependency. And in before_filer you load the menu data and send it to the view.

    In your default.ctp (or other layout file) you call the plugin helper with the data.

    Do a requestAction

    Create a method in your plugin controller and call requestAction: http://book.cakephp.org/2.0/en/controllers.html#Controller::requestAction

    So you can call: yourplugin/menus/index and it returns a full MVC process. So your controller in the plugin gets the menu items from the model, sends the data to it’s view and in index.ctp you render the menu. You get back the HTML result in your application, totally complete.

    Create a plugin with just a helper

    If you want the data in your model a plugin cannot help much but still: If you have a complex function which generates a well-styled menu you can put it in a plugin helper.

    In your application you do the loading by yourself in your application, so you have all flexibility there. You send it to the view but you use the plugin to render your menu. That way you can re-use your menu helper also without issues.

    Let appController extend your plugin appController

    Don’t like it but it is possible: You can create a new AppController in your plugin which handles setting up menu and all other things. You application appController then can extend that version instead of the normal AppController extends Controller. So you get: AppController extends yourPluginAppController. I don’t like this pattern in general though because the calls and dependencies are not visible anymore but really automatically added and executed.

    Optionally: For a more flexible way of working CakePHP has added the new: Events http://book.cakephp.org/2.0/en/core-libraries/events.html which is quite interesting. You could place interesting events in for example your appcontroller and attach listeners in the plugins for it. That would save you from hardcode calling those methods. So that might work out but it is quite new and there are some glitches because it’s brand new. Documentation is not yet complete and proven use of it has not been released much.

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

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.