Extended NewPage Module

By James KanjoJames 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:

  1. The inability to create hidden pages;
  2. The inability to create new pages on other wikis;
  3. The inability to type in a page, and automatically jump to it;
  4. The inability to specify the syntax of the new page's URL name (UNIX name);
  5. The inability to specify the syntax of the new page's title;
  6. The inability to specify pre-filled text;
  7. 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!

rating: +18+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License