[pmwiki-users] Link to create new wikipage

Hans design at flutesong.fsnet.co.uk
Mon Aug 15 15:54:28 CDT 2005

Monday, August 15, 2005, 9:29:55 PM, H. wrote:
> Could there be an option to move the button to the right?

Here is a newpagebox2.php script for box on left, button on right.
i also changed the default button text to 'Go' and inserted
'Create new Page' in the box, with onfocus and onblur changes,
i.e. when you click the box, the text disappears.
What I could not get working yet is the internationalisation of the
text in the box.

<?php if (!defined('PmWiki')) exit();

Markup('newpagebox', '>links',
  "NewPageBox(\$pagename, PSS('$1'))");
$HandleActions['new'] = 'HandleNew';

function NewPageBox($pagename, $opt) {
  global $ScriptUrl;
  $defaults = array('base' => $pagename, 'template' => '',
    'button' => FmtPageName(' $[Go] ', $pagename));
  $opt = array_merge($defaults, ParseArgs($opt));
  return "<form class='newpage' action='$ScriptUrl' method='post'>
     <input type='hidden' name='n' value='$pagename' />
     <input type='hidden' name='action' value='new' />
     <input type='hidden' name='base' value='{$opt['base']}' />
     <input type='hidden' name='template' value='{$opt['template']}' />
     <input class='newpagetext' type='text' name='name' value=' Create New Page ' 
     onfocus=\"if(this.value=' Create New Page ') {this.value=''}\" onblur=\"if(this.value=='') 
           {this.value=' Create New Page '}\" />
     <input class='newpagebutton' type='submit' value='{$opt['button']}' /></form>";

function HandleNew($pagename) {
  $name = @$_REQUEST['name'];
  if (!$name) Redirect($pagename);
  $base = MakePageName($pagename, $_REQUEST['base']);
  $newpage = MakePageName($base, $name);
  $urlfmt = '$PageUrl?action=edit';
  if (@$_REQUEST['template']) 
    $urlfmt .= '&template=' . MakePageName($base, $_REQUEST['template']);
  Redirect($newpage, $urlfmt);


More information about the pmwiki-users mailing list