[EXT_POPUP:link, width, height]link_text[/EXT_POPUP]

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

[EXT_POPUP:link, width, height]link_text[/EXT_POPUP]

Post by flip-flop »

Open a extern link in a new pop up window who is e.g. 800px wide and 600px high.

Code: Select all

<?php
/******************************************************************************
From: http://www.phpwcms.de/forum/

REPTAG CODE: [EXT_POPUP:link, width, height]link_text[/EXT_POPUP]
E.g. [EXT_POPUP:http://example.com, 800, 600]link_text[/EXT_POPUP]

Developer: k.Heermann (flip-flop) http://planmatrix.de
phpWCMS Version: >= 1.3.3

modified: 01.11.2008
last modified:  --

Description:
Open a extern link in a new pop up window who is e.g. 800px wide and 600px high.
-------------------------------------------------------------------------------

Installation:
	Put the code in frontend_render (for example in a file called rt_ext_popup.php)
	Enable in /config/phpwcms/conf.inc.php: 
	$phpwcms['allow_ext_render']  = 1;
	
Mod version: none

Support:
http://forum.phpwcms.org/viewtopic.php?p=110785#p110785
*******************************************************************************/

// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------

if( ! (strpos($content["all"],'[EXT_POPUP:')===false)) {

// inject the js function into head (since 1.3.3 ================
// If you are using an earlier version, please comment or kill this lines 
// and put the JS function into your template head section.
// <script type="text/javas .............. //--> </script>

$GLOBALS['block']['custom_htmlhead']['OpenWindow'] = '  <script type="text/javascript" language="javascript">

<!--
  function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>';

// END inject the js function into head =================

/* A little help ************
custom_link         = $1;
custom_win_width    = $2;
custom_win_height   = $3;
custom_link_text    = $4;
*****************************/

// Search parameter *********
$my_search		= '/\[EXT_POPUP:(.*?),(.*?),(.*?)\](.*?)\[\/EXT_POPUP\]/s';

// The replace parameter ****
$my_replace		= '<a href="#" onClick="MM_openBrWindow(\'$1\',\'New_window\',\'scrollbars=yes,resizable=yes,width=$2,height=$3\')">$4</a>';

// And do it ======
$content["all"] = preg_replace($my_search, $my_replace, $content["all"]);

} 
// END Only if [EXT_POPUP: exists ====================================

?>
[EDIT]
REPTAG CODE: [EXT_POPUP:link, width, height]link_text[/EXT_POPUP]
E.g. [EXT_POPUP:http://example.com, 800, 600]link_text[/EXT_POPUP]
[/EDIT]

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
Post Reply