By James Kanjo
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 two shortages of the inbuilt NewPage Module:
- The ability to specify static templates;
- A button (pressing "enter" will submit the new page, so there's no need for a button).
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 |
| 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 |
| 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.
Note: to use the # character without it being replaced by the user's input, you must type %2523 (escaped version of an escaped #).
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/
|text=Type in 'smile'
]]
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
Per Category CSS Module - 06 Mar 2012 03:38
Video Player - 16 Feb 2012 01:50
Specific Users Only Include - 16 Feb 2012 01:43
Remove Duplications - 16 Feb 2012 01:39
RegExp Date Wizard - 16 Feb 2012 01:39
"Random Page!" link - 16 Feb 2012 01:35
Quoted Blockquotes - 16 Feb 2012 01:33
NewPage Button - 16 Feb 2012 01:26
MP3 Player - 16 Feb 2012 01:25
JavaScript Addition - 16 Feb 2012 01:14
iframe Redirect - 16 Feb 2012 01:09
iframe embed - 16 Feb 2012 01:08
Random Page - 18 May 2011 09:50
Redirect - 11 Feb 2010 10:00
Rate this solution
If you think this solution is useful — rate it up!






Wow… looking forward to seeing this in action, James.
Portfolio
It's finally finished. If it were possible to specify static templates via the URL, I'd have done that too. That is the only feature that the inbuilt NewPage module has over this extension.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Uh… what the … o.O
I just noticed this as I'm going through my backlog of emails. This. Sounds. Incredible.
* goes off to test it out *
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
Request #1: Open in new windows/tab
It would be better if I could force the new page to be created in a new window/tab. Could you add that option?
Request #2: The ability to specify default text for the textbox
It'd be great to be able to specify some default text for the box… if that is possible.
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
Thanks for the suggestions Shane… they're good ideas, and I'll work on them.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
It took a while, but I've finally integrated the features you requested :-)
The reason it took me a while was because I decided to re-write the entire Javascript code — I made it unnecessarily complicated in the first place. Simplifying the code also removed all of the bugs in it too :-)
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
The new features are great!
I'm having a bit of a problem trying to figure out how to tweak the css of the input box default text. I'd like to darken it up a pinch or two, but can't quite get the element ID'ed properly. For example if I put style=color: #444; background-color: red; into the module parameter list, I don't see the default text change, but I do see a red border inside the input box. It seems that a white text background is coming from somewhere (my own css perhaps). Using Firebug, I see that the CSS is applied to the iframe element, but I think what I'm looking for needs to apply to the form element.
@James, can you document this a bit more with a list of attributes we can tweak? BTW, it's nice to see you active again!
Thanks,
Ed
Free Wikidot Applications · Your Shared Photo Gallery · Your Personal Blog
Thanks! Will be trying them out now.
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
Cheers guys! Glad you like it :)
@Ed, I manually darkened the text for you (#666), and I fixed the TextBox to have a transparent background (so now you can set the background colour yourself)… but dynamically changing the font style/colour is something that is a bit too complex for my limited spare time at the moment. Sorry!
However, when it gets done, it will be via specifying a CSS stylesheet to run with the module.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
OK, thanks for the tweak. It looks a lot better. After posting, I did see where the styling was done, but now that you've changed it, I won't have to mess with it. I'm helping another user set up multiple sites and am making great use of your talents with this and the SUO snippet.
Thanks again,
Ed
Free Wikidot Applications · Your Shared Photo Gallery · Your Personal Blog
Is it possible to have just a button with no textbox?
Scenario:
I am working on a Customer Management wiki (sorry it's closed to all but a few) [leiger and RhombusP have access.] In a Customer Record, I want a button that adds a new Work Order, as I already have set up auto-numbering and Page title format:[WO #%d] I do not need the NewPage button to have a text field as it's title is automated.
I have other senarios like; adding PC Details to a Cusotmer, adding Labour to a WorkOrder, etc, all of which do not really need to have text fields IF I'm using auto-numbering.
Current Use: Currently I'm using this;
What I'm Trying To Achieve:
Button + AutoNumbering + NewPage - Text Field
Thanks in advance
~ Paul
The NewPage Module is only useful for creating data based on the user's input.
What you are trying to achieve doesn't need User Input… so you can drop the idea of using a NewPage Module entirely.
Edit: See here for the solution to your problem.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
You can do that with just a simple link… but James has posted an even better solution — using a simple link + adding CSS to make it look like a wikidot button.
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
Hey Paul,
I went that one step further for you… and created the NewPage Button.
This should make things MUCH easier for you, as the syntax is virtually the same as the NewPage Module. Just to prove my point, I will use the example you provided me above with the NewPage Button:
The reason I did this is because you brought to my attention that this is something lacking in Wikidot. There's no easy way to create a NewPage link without having to learn the URL syntax… until now :D
Hope you like it.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
It's good to know that in between my incoherent babble, sometimes something makes sense. ;)
I'll be trying it out later, will post back. I'll be using this a lot! Thanks.
Actually, you were just trying to articulate something that you needed, but didn't exist yet…
That's the challenge for all programmers… trying to find solutions to problems that shouldn't exist.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Yes, my brain works in interesting ways sometimes. :p
I tried it out and it REALLY does the job. Great work.
I like it a lot! Appreciate it. :)
You might wish to be aware that if the extended newpage module is opening a page with a data form in the live template, the syntax must include name=something. If you omit this a normal page editor is opened and not the data form.
Sorry I should have posted in the extended newpage button page
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Strathview ~ Wikidot-based wikis, websites & intranets and online database development. For community groups, villages, charities, business and government.
Interesting. Is this the only way to directly edit a page that has a data form in the live template?
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
No you can edit it in the normal way. I was trying to create a data form page using the extended newpage button (hence I posted on the wrong page). It works fine as long as you have name= in the syntax. I can't seem to get the non-button version to work with data forms in live templates at the moment. I must be doing something silly.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Strathview ~ Wikidot-based wikis, websites & intranets and online database development. For community groups, villages, charities, business and government.
Hi Rob!
Yes, you need to have the |name= variable equal something. If you don't put anything in the |name= field, then the url will look something like this:
So you see, when you saw the normal editor instead of the data form, you were actually editing a page in the :_default category (which isn't a data form category).
This is also the same with autonumbered categories. You need to specify a page name to create the page (the page name is then changed to a number).
Does this help you a bit?
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
When I click edit, I'm presented with a data form. If I create a new page either by link or the NewPage module, I'm presented with a data form.
I didn't think that it was possible to edit a data-form-templated page without having to go through the data form to do it.
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
You can't, it's not possible. I wasn't clear enough:
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Yes I understood what you were saying perfectly James :)
I was replying to Ed in my post (which is why I quoted part of his post)
Shane Smith ★ Website: Wikidot Development & Programming. ★ STE Wikidot Editor: Windows. Mac. Linux. ★ Twitter. Google+.
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.
Strathview ~ Wikidot-based wikis, websites & intranets and online database development. For community groups, villages, charities, business and government.
Sorry, I was trying to add functionality, but I failed. Reverted to old version for now.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Thanks James, that's now working well.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Strathview ~ Wikidot-based wikis, websites & intranets and online database development. For community groups, villages, charities, business and government.
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
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…
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
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 :)
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
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 Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
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.
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript