CustomLinksToCreatePage
<< NoAuth | Cookbook-V1 | External links in new window >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Goal
This recipe helps you replace the default '?' that appears after a link to a page that doesn't exist, with something else like '[Create]'.
Solution
The solution is simply to redefine the variable $WikiPageCreateFmt to your liking. Here's an example which you can add to your local/config.php
:
$WikiPageCreateFmt = "<span class='createlink'>\$LinkText</span><a ". "class='createlink' href='\$PageUrl?action=edit'>[Create]</a>";
You might also want to add something like the following to one of your style files (.css):
A.createlink { font-size:64%; }
This class definition above will make the text '[Create]'
use a
smaller font.
Here is another example, where the link to create the page has also been given a title attribute. In many browsers the title is shown in a popup when you hold the mouse over the link, which in this case means that the user will get more information about what the link does.
$WikiPageCreateFmt = "<span class='createlink'>\$LinkText</span><a ". "class='createlink' href='\$PageUrl?action=edit' title=". "'Use this link to create the page \"\$PageName\"'>[Create]</a>";
Discussion
Remember that there are typically two steps to doing this customization:
- Specify the variable $WikiPageCreateFmt in for instance
local/config.php
- Optionally specify a special style of the create link in one of the style files that are included by your wiki pages.
Tip: It looks pretty good if you place the "[Create]" as superscript, using the <sup>[Create]</sup>
.
See Also
The implementation of this customization was discussed in this thread:
http://thread.gmane.org/gmane.comp.web.wiki.pmwiki.user:5702
History
2004-07-08: This page was created.
Comments & Bugs
For clarity, one can tweak the style files (.css) as follows:
A.createlink { font-size : 64%; padding-left : 3px; }
This will insert a 3-pixel space between the new Wiki page title and the [Create] label.
Or, you might omit the styling and use <sup>Create</sup>
, so the Create text appears as a superscript. And some wikis have a convention that links to create a page are red.
To get the supescript and still be standards complient, it would be better to change the style above to something like this:
A.createlink { font-size : 64%; vertical-align: super; padding-left : 3px; }
Rather than using the <sup>
tag
Or if you space wiki words, you might include the following:
$WikiPageCreateSpaceFmt = str_replace('$LinkText','($LinkText)', $WikiPageCreateFmt);
This will show a new page as (new page)? instead of new page?
Contributors
pmwiki-2.3.38 -- Last modified by {{vertigo25}}