Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is it possible to add a shadowbox.tpl.php file to the theme so that any url's loaded within the shadowbox use this tpl instead of the main page.tpl.php?
Alternatively, is there a way to detect if the shadowbox is being used or not?
Comments
Comment #1
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedyou mean a tpl to use for iframed shadowbox content? So that one could have a modal version of the content for viewing within the shadowbox window?
Comment #2
iancawthorne CreditAttribution: iancawthorne commentedYep exactly what I was thinking. Is it possible?
Comment #3
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedyou can add as many tpl's as you like to your theme, you just need to add a template suggestion. Example:
Let me know if that solves your issue.
--
Los Angeles Web Design and development for Drupal.
Comment #4
iancawthorne CreditAttribution: iancawthorne commentedThat's for looking at this. It seems pretty close, the only part that is not quite right for me is the detection.
The snippet above seems to detect if a variable has been set in the $_GET.
I was hoping to detect to use the correct tpl file if the shadowbox is active, unless I have misunderstood?
Comment #5
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI am not too sure of a way to really do what you are asking. What I suggest is creating content type called say, "Shadowbox Page" (namespace "shadowbox_page") and you can apply a custom theme to those pages.
Then just create a page-node-shadowbox_page.tpl.php and all of these pages will show in a shadowbox. Unfortunately I don't know of any way for javascript to essentially tell PHP which template to use, which is what you are kind of asking for.
--
Los Angeles Web Design and development for Drupal.
Comment #6
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedActually the more I think about it, I bet we could just use some jQuery to tack on the variable in the $_GET whenever the links is set to open in a shadowbox. That would keep you from having to alter your links via hard code. Let me know if that seems like an adequate solution for you.
--
Los Angeles Web Design and development for Drupal.
Comment #7
iancawthorne CreditAttribution: iancawthorne commentedThanks for getting back on this.
The ideal solution would be to detect if the page is within the shadowbox or not but it sounds like the jquery to add on the variable would do the trick as a work around solution. Then you can pick and choose virtually anything.
Could you give an example of how to add the variable on using jquery?
Most of my requirements are for .form-submit as the click event.
Comment #8
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedSome variation of the code I used in #770990: Possible to exclude certain elements? (views galleriffic compatibility problem) should work:
--
Los Angeles Web Design and development for Drupal.
Comment #9
iancawthorne CreditAttribution: iancawthorne commentedThanks, that works perfect on hyper links.
Is there a way to apply this to form buttons?
Comment #10
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedNow I am not completely sure what it is your button is programmed to do, so I don't know what to put in the middle of that code. Hopefully this should give you some headway on usage however.
--
Los Angeles Web Design and development for Drupal.
Comment #11
iancawthorne CreditAttribution: iancawthorne commentedSorry, I should have been more specific.
The main usage is for node add / edit forms and comment forms (attempting to use shadowbox like the overlay module works in Drupal 7).