By James Kanjo
Please Note:
The code for this snippet was updated in May 2014.
There is now an enablebutton attribute which you need to set to true if you want the button to be displayed.
Description
Quite similar to the built-in NewPage Module, this snippet provides a way for you to create (or jump to) new pages.
The built-in module has seven limitations:
- The inability to create hidden pages;
- The inability to create new pages on other wikis;
- The inability to type in a page, and automatically jump to it;
- The inability to specify the syntax of the new page's URL name (UNIX name);
- The inability to specify the syntax of the new page's title;
- The inability to specify pre-filled text;
- The inability to open new pages in a new window.
These limitations don't exist with the Extended NewPage Module, which allows the use for a more powerful Wikidot applications.
This module comes with one shortage of the native NewPage Module:
- The ability to specify static templates
Attributes
The Extended NewPage Module extends upon the NewPage module — therefore, it has identical attributes to the built-in NewPage Module:
attribute | required | allowed values | default | description |
---|---|---|---|---|
category | no | name of a page category | none | forces the given page category by prepending the page name by the categoryname: |
size | no | em, % or px | 200px | size of the displayed input field |
button | no | any string without "double quotes" | Create Page (however, is turned off if left blank) |
changes the text of the button |
format | no | any valid regular expression | none | forces the input value to match the required format |
tags | no | space-separated list of tags | none | automatically adds given tags to created pages |
parent | no | name of a page or category:page | none | automatically adds parent page to created pages |
Extended Attributes | ||||
mode | no | manual | none | allows you to nest the Extended NewPage Module within other modules (read more) |
window | no | new, false | false | if new, will jump to new page in a new window |
enablebutton | no | true, false | true if "button" field is not empty, false if "button" field is empty |
if true, the button is visible if false, will prevent the button from appearing; |
text | no | any string without "double quotes" | none | pre-fills textbox with custom text |
site | no | full site name (i.e. http://www.wikidot.com/) | current site | creates new pages to the given website |
name | no | any string, # optional | page title (as specified by the user) | sets the syntax of the UNIX page name |
edit | no | true, false | true | if false, will jump to the page without force editing it |
title | no | any string or false # optional | page title (as specified by the user) | sets the syntax of the page title. If “false”, the /title/ will be removed from the URL |
url_end | no | any string | none | appends the string you specify to the end of the URL (for advanced users) |
style | no | any styling attribute | none | changes the style of the iframe (the NewPage textbox) |
prepend | no | anything you want before the include code | [[module ListPages range="."]] | for advanced users |
append | no | anything you want after the include code | [[/module]] | for advanced users |
The optional # character is replaced with the text that the user types in.
For example, if your code contained |title=You are # and the user typed in “silly”, then the created page would have the title: You are silly.
Important Note on Escaping Characters
Character | Replace With | Reason |
---|---|---|
| Pipe |
%7C Escaped Version |
As the include syntax parses this character as variable delimiters, this character must be escaped in order to be used |
# Hash |
%2523 Escaped Version of an Escaped Version |
As a feature of this CSI is that this character gets replaced with the user's text-box input, this character needs to be escaped in order to be displayed literally |
Code
This code will attempt to create the page "wikidot". The page's title must contain the word "smile" in it.
[[include :snippets:newpage
|name=wikidot
|format=/smile/
|edit=false
|text=Type in 'smile'
|button=Jump!
]]
In action
Manual Mode
The Extended NewPage Module uses technologies from the ListPages Module to automatically identify your website's address. Sadly, Wikidot doesn't yet allow nesting modules (such as having a ListPages module inside another ListPages module). This means that under normal circumstances, you can't use the NewPage module inside of a ListPages module.
However! You CAN use the Extended NewPage Module inside other modules, but only through the use of “Manual Mode”. Manual Mode removes the inbuilt ListPages Module from the Extended NewPage Module. Doing this means that you need to manually specify the website address that you wish to create pages on:
[[include :snippets:newpage
|mode=manual
|site=http://www.wikidot.com/
]]
Thanks to tsangk for this great snippet: conditional-blocks
text above inserted with:
[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]
Other snippets posted by James Kanjo
Rate this solution
If you think this solution is useful — rate it up!
Would it be possible to create 2 pages at once using this module? I'm trying to create a way for users to name their own categories, and to give each category it's own live template (using a static default template)
If I were to put
[[include :snippets:newpage
|name=#:story
|name=#:_template
|button=Admin Only
|size=30
|edit=no
]]
Would this be able to create two pages with the name typed in the box?
I am affraid, without changing the script behind it this is not working.
It makes sense to create a live_template for each user-category, but this is better done in an extra step on a "new-user" page ( perhaps with iftags and stand alone buttons ), a new story is creatd mor often tha the template.
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
thank you for your help, I will continue to think on the issue.
FYI: ENP Module Now Includes Button!
What's that? There's a button now?
So rather than hitting the "Enter" key after typing in input, I can instead lift one hand from the keyboard to the mouse, position the cursor on the button, and click it! Awesome! Much more efficient!
I seem to read all documentation and spent hours trying to fix it, now I'm stuck, please help
here is what i'm tryign to do: I have parent page, which should show its children. Then user should be able to add a child. Child should be added to current page as "parent".
I tried NewPage module as
and it works fine. Here http://sky-tests.wikidot.com/test:page-two I created pages "child1" and "child2".
Then I create one more parent page http://sky-tests.wikidot.com/test:page-three and tried to add a child with same name "child1". it complained with error:
"The page testchild:child1 already exists. Jump to it if you wish."
Therefore I need not only create child pages, but with some uniqness in it's name.
so, i found page when it is actually working http://vineyard.wikidot.com/band:queen
there the one can add band members and they never collide with other bands
the code looks like
I added that code to my page, but unfortunately it does not work: it creates one child page and then any other attempts to create new child page will result editing the first one.
the question: how can i create child page with will either:
1. have some unique number / name or
2. have name like "parent-page + text user typed in the edit box"
this should be something simple but i stuck. It would be nice to have more code samples in the original description
thank you in advance.
P.S.
I tried to use
but it also will always create one page named "new-page".
is it possible to generate new page name based on
"parent-page title (name) + text what user typed in the edit box?
I beleive the category "testchild" should be set to "autonumbered" in the site manager! than ever ynew page is autonumbered with the standard page name 1, 2, 3, 4 a.s.o and the title as the creator wished…
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
thank you that helped!
thank you for your snippet. Unfortunately it is not support any language except English
for example, this code
will now result string "hello in russian is == привет" as hint, but will generate garbage text
sorry for dublication please remove message above
I'm not sure why that happens… I'll look into it
At the time of this post (469 days after the birth of ENP), there are 175 pages on Wikidot using this technology!
I noticed that in cases where the user types in a regular expression that is incorrect, the module will fail to work when the user submits the input.
Now there is an implemented solution to this: an error message lets the user know that an invalid regular expression was used to construct the module.
I have the feeling - all CSI-used "snippets" ( and their codes) should be blocked by the authors when working well and sre finished in the creating setup - to make them secure against trolls or changes wihtout any need…
Means - even a new version by the author himsels should be copied to a new version-numbering to secure the running version of codes?
What is your oppinion?
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
Hmm.
I suppose restrict the permissions to “only edit pages owned by me”. That way anyone can create pages, but they can't edit other people's pages. Perhaps only members of Snippets should be able to edit other people's snippets.
This is a good idea, seeing as some of the CSIs here are quite heavily used.
James (or other guru), is it possible to include the current date and/or time in the url output?? So that if the user's input is this is my page, the url becomes something like…
Thanks,
Bryce
BMC Creative | RoaringApps | @brycecammo
Sorry, I don't think that is possible…
Oh really? Well how about this then! Ah ha!
May I warn you to prepare to cringe at my very rudimentary, nigh nearly non-existent Javascript skills. Yet my determination to make this work somehow produced a semi-alright result. Critique welcome…
BMC Creative | RoaringApps | @brycecammo
Oh sorry! I misunderstood you! I thought you meant creating pages based on the current page's creation date!
Very neat and tidy javascript, by the way :)
This may be blatantly obvious, but it was a big 'ah hah!' moment for me…
If you want the user's input to also be created as a page tag, just put:
This is particularly useful for selecting pages with the ListPages module. And it just made my life a whole lot easier.
Cheers,
Bryce
BMC Creative | RoaringApps | @brycecammo
Have you done something to break this snippet James? At the page here I just get a "No such page" error message whenever I try to create a page using
It should create a page with a dataform on it. I tried it on another site with a standard page but still get that message. I'll go back to using the buttons for the time being.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Sorry, I was trying to add functionality, but I failed. Reverted to old version for now.
Thanks James, that's now working well.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.