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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:28:22+00:00 2026-05-24T13:28:22+00:00

I am dynamically loading content into my modals, and often it will be a

  • 0

I am dynamically loading content into my modals, and often it will be a page that is already a normally accessible page on my site.

So I want to be able to reuse that controller/action and load it into my modal but obviously the controller already uses a layout. So when I load the page into my modal, the header and footer of my site is all in the modal again, which I don’t want.


One solution I thought of that might work, but seems like a dirty workaround, is to have in my Appcontroller a check for a URL parameter that says it is a modal call for the page (not a regular call). It then overrides the layout with a special modal one.

//app_controller.php

public function beforeRender() {
    if (isset($this->params['passed']['_modal'])) {
        $this->layout = 'modal';
    }
}

// In my jQuery call to open the modal:

myModal.load('users/view/5/_modal').dialog('open');

Then in the modal.ctp layout I would include a stylesheet that looks something like:

// modal_layout.css

@import url("normal_layout.css");

.header, .footer {display:none;}

So I don’t have to redefine all of my normal layout’s CSS but I can just hide the parts I don’t want to show.

This seems like a bit of a stupid method of doing it, and I don’t know if it even works, but surely someone has had to do this before with CakePHP, so what would you guys suggest?

  • 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-24T13:28:24+00:00Added an answer on May 24, 2026 at 1:28 pm

    It turned out I didn’t need to anything so complex. I simply created a hidden div in my layout:

    <div id="modal"></div>
    

    And then in my layout’s existing CSS I added certain rules to hide elements I don’t want to see when a page is loaded in a modal:

    #header, #footer {display:none;}
    

    That way I can load a page into the modal but it still has all the normal styling that is already defined in the layout’s CSS. Pages are loaded into the modal by using their normal CakePHP URL:

    $('#modal').load('controller/action/param:whatever').dialog('open');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading some text dynamically into a div, but have the problem that
I'm dynamically loading content into a div when the user clicks a link using
I am loading content with jquery.load() (1.4.2), which includes a form that I turn
I'm working on an AJAX based application that is dynamically loading in resources (external
I am loading some images dynamically into a UITableView and creating some simple custom
I'm dynamically loading user controls adding them to the Controls collection of the web
I have an application where I'm dynamically loading routes by a model, and calling
I have recently come across a situation where code is dynamically loading some libraries,
How would you dynamically subscribe to a C# event so that given a Object
I have some dynamically created inputs which are not server-side controls. I want to

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.