We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7155
    • 160 Posts
    Hi

    I have a snippet that opens a modal window using Javascript’s window.open(...) method. The challenge I have is that it opens with the default template included.

    How do I reset the <head> contents so that I have a window without the default template, but still within the scope of MODx.

    Thanks,
    Tino
      • 10487 MODX Staff
      • 1,535 Posts
      Garry Nutting Reply #2, 17 years ago
      If your lightbox is a MODx page, just define a new template with your required <head> contents etc., and assign it to the page.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 7155
        • 160 Posts
        Hi, thanks for responding.

        The window that pops up is not really a new page. But the index.php page with some chunks I would like to place in it. The part about generating and displaying chunks would not be a problem. The challenge is getting it to start blank without a template.

        An example is the way QuickEdit works. When you edit content on front page, the pop up is actually index.php with query strings for further processing(correct me if I’m wrong). That’s what it looks like outside the hood.

        I guess I’ll have to look into the way QuickEdit was done but I would really appreciate a clear cut way I can do it, if its available in MODx. I thought there would be a method similar to $modx->regClientScript, but flushes the <head>
          • 7155
          • 160 Posts
          grin
          I’ve thought up a simple solution. I got direction from your suggestion, garryn

          In the default template I will have some conditional processing through either PHx or a snippet call that decides whether to show the default or blank setup!!!. i.e it determines whether to load the css,js,menu...etc or not

          It seems possible.

          What I will have to do is either note the documentIdentifier of the page that calls my snippet or create a session variable which will be used to test the condition.

          It makes logical sense. Will see if its practical!
            • 7155
            • 160 Posts
            I have a feeling it will be expensive, resource-wise or computationally.
              • 10487 MODX Staff
              • 1,535 Posts
              Garry Nutting Reply #6, 17 years ago
              I still don’t see why you can’t have a lightbox-specific document within MODx which utilizes a lightbox-specific template and run all lightbox requests through that. In effect, that is what you’re trying to hack into the template with the above solution - it’d be much more efficient to just go with a separate document.

              As all MODx documents pass through index.php, you’d have access to the full MODx API, snippet and chunk processing etc.

              Although, it depends largely on what your lightbox is trying to do - is this going to be a site-specific setup or are you trying to create something that can be installed on multiple sites?
                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com
                • 7155
                • 160 Posts
                This is my scenario:

                Front-end:
                The snippet searches through certain data from the database.

                On each search result, there is a link that opens a pop-up window...without intention of getting rid of the search results. The user clicks a link, the pop up window appears then he/she submits an enquiry on that particular search result. The user can close the pop-up window, scroll down the other results and submit enquiries as he/she desires.

                Backend:

                The link that pops up a window contains a query string that is then accessed by the snippet to process the submission. The snippet also places a chunk within that pop-up window.

                I cannot say I am fully able to think in MODx, but I thought to get rid of the template, I would have to place conditions in it. I would like to hear your suggestion on the best approach...bearing in mind that the search results should be preserved
                  • 7155
                  • 160 Posts
                  I think I am now making sense of your suggestion, garryn...brain cells are on slow mo wink

                  I should create a page with the blank template I desire, taking note of its ID

                  Then pop up that page when the link is clicked

                  Then maybe call my snippet on the pop up page with the submit action I desire and getting whatever query strings I pass to it. e.g. [!MySnippet? &action=`submit`!]

                  makes sense...if I’m right

                  Thanks for listening
                    • 10487 MODX Staff
                    • 1,535 Posts
                    Garry Nutting Reply #9, 17 years ago
                    Yes, that’s exactly what I’m suggesting smiley
                      Garry Nutting
                      Senior Developer
                      MODX, LLC

                      Email: [email protected]
                      Twitter: @garryn
                      Web: modx.com