NewPageBoxPlus-Talk

Summary: Talk page for NewPageBoxPlus.
Maintainer: HansB
Users: +5 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Comments and Questions

  • Very nice. Would it be possible to include a short descritpion of the parameters into the script itself? So the meaning and function of the parameters could be easily obtained without need for searching for it. You should integrate also the possbility that someone only adds a group name for base. Ok this is a minor one. Klonk January 11, 2006, at 03:07 AM
    Done the documentation. ~'HansB''
  • Would be nice if this could check to make sure the textbox is not left empty (or is still equal to the "value" parameter) - so that inadvertant editing did not happen.
    Fixed now. ~HansB
  • Is it possible to place the newpagebox in the very top line near "recent changes" and "search" ? ~~Peter, 2006-03-02
Assuming you are using the default pmwiki skin, you would need to edit the skin template and css file: In pmwiki.tmpl place <!--markup:(:newpagebox:)--> after <div id='wikihead'> (plus any parameters in the markup), and in pmwiki.css add #wikihead form { float:right }, which will force the forms to stay side by side, and not in two lines. ~HansB
  • If I set save=true, then no author-information is saved. So $LastModifiedby is "". What can I do? flox April 10, 2006, at 04:42 AM
I added author name when new page gets auto saved and changed code so page will appear in RecentChanges even with auto save. ~HansB
  • How complex would it be to tweak this to create a newgroupbox, where the base and the entered value are turned around? I want to have a box where someone can enter the name of a new group, and Group.Base is created, instead of Base.Group. -- JonHaupt
Here it is: see NewGroupBox -- HansB
  • With (:newpagebox .... save=true:) a new created page has 1970-01-01 in $PageCreationDate with:
    # add page variable {$PageCreationDate} in format yyyy-mm-dd
    $FmtPV['$PageCreationDate'] = 'strftime("%Y-%m-%d", $page["ctime"])';
    in config.php. flox April 15, 2006, at 02:57 PM
With save=true the new page did not have ctime set. I updated the script so it now saves also a ctime page creation time stamp when auto saving. -- HansB
As everytime: Thank you very much! flox April 16, 2006, at 03:40 AM
  • If a page is created (save=true), sometimes the page is not listed with (:pagelist:). There seems to be no problem, if I create one without this script. Profiles April 18, 2006, at 12:42 PM
Could you say under which pagelist conditions (parameters) this occurs?

I know, not the best code...

(:pagelist fmt=#galerienormal group=Galerie -2004 -2005 -2006 list=normal -IchHabDichLieb 
-RecentChanges -PageTemplateName -GroupHeader -GroupFooter -GroupAttributes :)

If I create for example the page hallo, it isn't shown there. But it lists "old" pages. Sometimes, if I edit the page again, it is shown in the pagelist. Thanks, flox April 18, 2006, at 03:53 PM

I advise to narrow down the parameters you use, to see when the fault kicks in. You also use -name -name2 etc a lot, and probably want to exclude pages with those words as title. For that it would be better to use name=-name1,-name2 . list=normal should also exclude RecentPages and GroupHeader, GroupFooter GroupAttributes automatically. Finally the reason may be in the fmt=#galerienormal, perhaps you can show it, after trying eliminating other parameters. -- HansB
  • I'm using save=true and template=Xxx. If the template has markup that adds it to a category (e.g. Yyy), then the new page doesn't appear in the category listing (pagelist link=Category.Yyy) unless I edit that page.
    I updated the script, so link targets are saved as well now. -- HansB April 28, 2006, at 03:40 AM
    Hi Hans, that does work. I ran into problems as was using both NewPageBoxPlus and NewGroupBox on the same site - the latter was included second in the config file and still had the old code. The handler for NewGroupBox appears to overwrite the handler for NewPageBoxPlus when included in this order, it took a while to figure this out and get your changed code working for me. Thanks for your work and quick reply!
I changed the handler name in newgroupbox. Thanks for pointing this out! -- HansB May 01, 2006, at 02:38 AM
  • Can you add an option to strip periods (".") from the input? If a visitor uses a period in the input, the specified base group is overridden and the new page is created in a different group, based on the entered string, e.g. "John Q. Public" creates JohnQ.Public (that is, a page called Public in a group called JohnQ). Pico May 17, 2006, at 05:48 PM

Done now. Periods gets stripped if a base= parameter is specified. If no base= is specified the left side will become the group, and the right side of the period the pagename, which lets you create pages in other groups than the current. HansB August 05, 2006, at 01:28 PM

  • Can you add a parameter that puts the link to the new page on the original page right above the markup? It would be great for lists of links. Alex 5th Aug 2006

I think this feature goes a bit beyond the scope of this recipe, it will require rather complex alterations, as the page with the newpagebox markup needs to be changed and saved automatically, apart from creating the new page, which is newpagebox's job. You could perhaps use the (:pagelist:) directive instead. If new pages get created in various groups perhaps set up a template page with a marker on it, like (:comment SpecialMarker:), and use (:pagelist SpecialMarker:) above the newpagebox to list links to all pages with SpecialMarker. HansB

  • Hans, is there a way to use Newpageboxplus with wikiforms? I would like to use a Wikiform that has a button like 'Create new note' or 'create new page' where both the groupname and pagename can be set with variables. Am I making sense here? (hfwang-aug192006)

You can install newpageboxplus and use input form markup like

(:input form :)
(:input hidden action new:)
(:input hidden name "Test.NewPage":)
(:input submit value="Create new page":)
(:input end:)

This will create a button which when clicked will direct to edit a new page named Test.NewPage. You may want to use variables for 'Test' and 'NewPage'. But I am not sure how you apply them, I did not understand your concept for this. Still the input form will use the newpagebox functions. You could also add more hidden fields, for instanc efor a template page:

(:input hidden template "Templates.NewPageTemplate":)

~HansB

Hans, thanks for the swift reply! Let me clarify my wishes a bit.

I am using wikiforms to create a 'project information sheet' page. From this page I would like to be able to 'press a button' to create 'issues', 'notes' etc. all in their own group and manageable with wikiforms. New sub project entries must link to the original project (xxx.0001) and list themself on the ViewTemplate page of the wikiform page. In Short, Projects is the main entry to all information, but issues and notes do have their own page where all of them (thus all projects) are listed as a reguar 'wikilist' entry. HTH! (hfwang-aug192006)

I am sorry but I know nothing about WikiForms, you better ask John Rankin. ~HansB

Possible Solution: I have been tracking for a while the posts of HTH, I have been working in a similar project as well, I think I maybe have found a solution for his application. If you take the following line in the newpageboxplus.php:

" <input class='inputbox newpagetext' name='name' value='{$opt['value']}' size='{$opt['size']}'" . ($opt['focus']=="true" ? $onfocusHTML : "") . "/> \n" .

and then changed for the following :

" <input class='inputbox newpagetext' type='hidden' name='name' value='{$opt['value']}' size='{$opt['size']}'" . ($opt['focus']=="true" ? $onfocusHTML : "") . "/> \n" .

This basically hide the Input Text Box. You will get a imple button linking to the page you want to create in the form:


(:newpagebox base=P{$Name}.Main value=Main label=Go button=left save=true:) 

(:newpagebox base=PNewPageBoxPlus-Talk.Main value=Main label=Go button=left save=true:)


and you yet have the option to specify the template you want to use with with.

Hope that Helps, Marte

  • Could you add a prefix= or suffix= or pattern= option, so that the new page name would have that as part of its name? This isn't the same as base= (which determines the group name); I need something that would affect the page name. For example, if the entered name was NewPage, and the prefix was Foo, then the real new page name would be turned into FooNewPage.
    Kathryn Andersen January 23, 2007, at 07:31 PM
I added prefix and suffix optional parameters to the script. - HansB January 24, 2007, at 05:39 AM


I was looking for a way to have an input select drop down for groups and found this to work in a form (based on the input form markup above:

(:input form :)
(:input hidden action new :)
(:input text name :)
(:input select name="base" value="SomeGroup1" :)
(:input select name="base" value="SomeGroup2" :)
(:input submit value="Add New Page":)
(:input end :)


Seems to work well for me ... so I thought I'd post if for others to see. ~Scott

  • Hans, nice recipe. Could you add an option to skip going to the new page altogether? (even when the page already exists). SteP March 10, 2007, at 05:37 AM
Why would that be desireable, what do you wish to achieve? If not redirected the user has no clue as to what happened (even if nothing happened). - HansB
  • Well the page with (:newpagebox:) also includes (:pagelist group=NewPages:) this way I know when a new pages is created. I have no need to edit the new page, so I want to stay where the creation box is. I like that NewPagesBoxPlus doesn't complain when it can't create a page.
  • I need to change my initial request, could you add an option to go to a "feedback page" --which could also be the current page--and by default is the new page? I would use (:newpagebox goto={$FullName}).
  • NewGroupPage is a very nice recipe, too. I use it to move an existing page set to another group. I like the way that this recipe doesn't complain when some pages already exist. Could you add a "goto" option here too?
  • In both NewPageBoxPlus and NewGroupPage I would also like to hide the text input field, so a user could only press the "Create" button. Is this possible?
  • To move a set of pages from OldGroup to NewGroup I use NewGroupPage as follows: (:pagelist group=NewGroup fmt=#inputcheckboxarray:) creates a csv list of user-selected pages in {$:selected}, then (:newgroupbox base=NewGroup autopages={$:selected}:) copies them to NewGroup, then a ZAP delete action removes the copied pages from OldGroup. SteP
  • Would it be possible to make the newpagebox open a new window when you hit "Create"? -Julie, August 20, 2007 at 07:13 PM
  • How would one go about getting NewPageBoxPlus (or NewGroupBox) to complain if the group or page already exists? It would be nice to be able to turn this function on - with the result being a post to (:messages:) on the same page... overtones99 April 26, 2008, at 03:39 PM
  • Note: BUG(?) - after toiling around with the recipe for a bit, i've noticed that the result in setting save=true and save=false is no different - it redirects the same everytime (to the saved page). rather - i found that setting save=1 and save=0 actually redirected correctly - to the actual page in the former, and to the edit-mode version in the latter... overtones99 April 27, 2008, at 12:53 AM
  • it appears that a creation time is not added to the new page, except under certain circumstances - in my case, the creation times are not being added as a result. so, in my own copy of the recipe, i've moved the ctime instance out of the conditional block, as so, and it seems to work better for my purposes (i.e. i get a correct creation time that's not 31 Dec 1969 everytime...):
                
		if (@$_REQUEST['template'] && PageExists($_REQUEST['template'])) {
			$p = RetrieveAuthPage($_REQUEST['template'], 'read', false, READPAGE_CURRENT);
			if ($p['text'] > '') $new['text'] = $p['text']; 
			$new['author'] = $Author;
			//$new['ctime'] = $Now;   // taking it out of here...
		}       
                $new['ctime'] = $Now; // ... and sticking it here instead...

overtones99 June 02, 2008, at 05:40 AM

  • hi, i would like to copy some PTVs in hidden field to the new created page. Hope you can help me. thank you.

hendrik June 16, 2008, at 05:49 PM

If you want that much, I would recommend you create a NewPage form with Fox, which lets you add all you need. HansB June 17, 2008, at 06:58 AM


Hans, I would like to use this markup as its exactly one of the things I need, however, after I have the people make a new page, how does this markup place a link somewhere? Because if not, the page will never be found. Thanks, Chris November 12, 2019, at 02:50 AM

newpagebox does not place any page link anywhere. This would need to be done manually, or dynamically for instance using a pagelist markup. HansB October 03, 2008, at 09:46 AM

I would suggest a pagelist because it allows you to do some awesome things. Have a look at my Mobile group page, that page has only one working line on it:

(:pagelist group=Mobile fmt=#titlesummary list=normal:)

In fact, all my group pages are using a single pagelist directive now, it's much easier and saves a lot of work. I use new page box plus and the new pages that are created are automatically included in the appropriate group pages because of the pagelist directive.. I don't have to make any links unless I create a new group. Ian MacGregor


2008-10-02 I'm now using this recipe on my site and it's working perfectly. Thank you for writing this wonderful recipe. Ian MacGregor


2009-01-20 Hans, you may wish to consider changing the first line of HandleNew so that

    $name = stripmagic(@$_REQUEST['name']);

This way, entering "John's dumb test" produces a page called JohnsDumbTest instead of JohnSDumbTest. The reason: single quotes get back-slashed, MakePageName turns the quote into a null, then turns the back-slash into a space, and the resulting space-s is turned into S. The stripmagic removes the back-slash before MakePageName runs. This makes the behaviour consistent with pmwiki: [[John's dumb test]] links to JohnsDumbTest. jr


2010-03-23 If you give a slash "/" in requested Page Titel the page will created in group "Main". To avoid this I've added at line 99 in newpageboxplus.php:

97:	if (isset($NewPageBaseGroup) OR $_REQUEST['base']) {
98:		$name = str_replace(".", "", $name);
99:		$name = str_replace("/", "", $name);
100:		$newpage = MakePageName($base, "$basegroup.$name");	
101:	}

that replace the slash. Peter

Talk page for the NewPageBoxPlus recipe (users).