Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

PopupWindow

Summary: create popup windows
Version: 2008-04-17
Prerequisites: pmwiki 2
Status: stable
Maintainer: DaveG
Categories: Links

Questions answered by this recipe

How can I create popup windows?

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

Description

Enter your recipe's description here. Download popupwindow.phpΔ, copy to in cookbook directory and install by adding to local customisation file:

include_once("$FarmD/cookbook/popupwindow.php");

This adds the markup %popwin parameters%[[link]]. [[link]] is a standard wiki link. Parameters can be none for default popup, or any of the following (defaults are shown):

  • id= 0, give each popup link a different id number.
  • width= 500, window width in pixels .
  • height= 300, window height in pixels.
  • left= center, window position from left in pixels. left=center will horizontally center the popup window to the screen.
  • top= center, window position from top in pixels. top=center will vertically center the popup window to the screen.
  • resizable= 1, boolean, window can be resized.
  • scrollbars= 1, boolean, show scrollbars.
  • toolbar= 0, boolean, hide toolbar.
  • location= 0, boolean, hide url location bar.
  • directories= 0, boolean, hide links bar.
  • statusbar= 0, boolean, hide statusbar .
  • menubar= 0, boolean, hide menu bar.

Some of these will not always work in all browsers. Some are dependant on user settings in the browser. Popup links can be configured to pass different parameters for different links, by adding a unique id= number as a parameter.

Additional markup:

  • (:popclose Close Window:) creates a link for closing the popup window, replace "Close Window" with whatever label text.
  • (:input closewindow 'Close Window':) creates a 'Close Window' button. Replace "Close Window" with whatever label text.
  • ?action=popopen used in the link which opens the popup will set a page variable {$PopOpen}. This can be used in the popup page in conditionals to trim side menus etc:
(:if equal {$PopOpen} 1:)(:noleft:)(:popclose Close Window:)(:ifend:)

This will ensure the page functions normally when not opened as a popup, but it opens without the SideBar and with a "Close Window" link when "popped up" with %popwin% and when adding ?action=popopen to the link as here:

%popwin%[[PageName?action=popopen| link text]]

Examples:

%popwin%[[Group.PageName]] : popup a default window, centered to screen.
%popwin top=20 left=20%[[Group.PageName| link-text]] : popup a default window 20px from left and top.
%lfloat%%popwin%[[Group.PageName| Attach:thumb.jpg]] : float a picture link, popup a default window.
%popwin width=300 height=200 scrollbars=0%[[Group.PageName]] : popup a window size 300 by 200 with no scrollbars.

Notes

Release Notes

  • 2008-04-17: Added (:input closewindow 'Close Window':). Modified (:popclose label:) markup to make it more secure. Changed function so javascript gets loaded as part of the popup link.
  • 2007-03-20: Added (:popclose label:) markup for link to close popup. Added action=popopen which creates a page variable {$PopOpen}. This can be used in conditionals in the popup page.
  • 2006-11-20b: Changed default position from top left corner to screen centered.
  • 2006-11-20a: Revised markup. Added another markup to cater for [[linktarget | linktext]]-type links
  • 2006-11-20: Initial release.

Comments

There's an annoying side effect when using images in link descriptions: the width and height parameters are both interpreted for the popup window geometry and the description image size, as in: %popwin width=300 height=200 scrollbars=0%[[Group.PageName|Attach:FaultyResizedImage.jpg]]
-- Dfaure February 11, 2007, at 04:58 PM

  • This problem isn't happening for me. Let's get the recipe enabled on this page and see how it works; I've added "update me" to the category. -- Tegan Dowling

Has anyone tried using this for a link in the sidebar when the current page is not "Site.Sidebar"? For example, edit the sidebar to use this, save, then navigate somewhere else. Does the sidebar link still work? -- lordmundi July 10, 2007, at 07:48 AM

See Also

Contributors

Sandbox

%popwin width=700 height=500%[[Test.PopUp]] without action=popopen

%popwin width=700 height=500%[[Test.PopUp?action=popopen| PopUp]]

normal:%newwin%[[Test.PopUp| PopUp]]

Test.PopUp without action=popopen

PopUp

normal:PopUp

%popwin width=700 height=500%[[Test.PopUpTrimmed]] popup a trimmed page

Test.PopUpTrimmed popup a trimmed page

Comment

Hi - Thanks for this cookbook. I really like $PopOpen features which works great except I have fixflow skin, which has an extra header menu called PageTopMenu and an extra footer menu called PageFootMenu. The commands to turn these off are (naturally) notopmenu and nofootmenu and are built into the skin. So at the end of each page that I want to use both as a regular page and a popup window, I add the line

(:if equal {$PopOpen} 1:)(:noleft:)(:noright:)(:noheader:)(:nofooter:)(:notopmenu:)(:nofootmenu:)(:popclose Close Window:)(:ifend:)

and then on the page where I want the link to bring up a trimmed popup window I write the link as:

%popwin%[[myPopupPageLink?action=popopen|myPopupPageLink Text]]

and get a perfectly trimmed page with the Close Menu button. Thanks. LFS

Edit - History - Print - Recent Changes - Search
Page last modified on April 17, 2008, at 07:29 AM