DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:shorturl

shorturl plugin

Compatible with DokuWiki

2009-12-25c - 2011-05-25

plugin Creates short URLs to internal wiki-pages, based on redirect plugin

Last updated on
2010-12-12
Provides
Syntax, Action
Repository
Source

Tagged with links, redirect, shorturls

Download and Installation

Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.

Changelog

  • Fixed bug in hex to dec conversion leading to shorturls like “aaaaaa” (2010-12-27)
  • Added helper class (2010-12-12) :!: template integration changed :!:
  • Initial realease (2010-11-30)

Syntax and Usage

German documentation can be found here

You can use the plugin as syntax plugin in a wikipage. Simply insert

~~SHORTURL~~

in the page, so the short URL will be created upon saving the page and a link will be displayed pointing to the generated URL.

If you want to use the functionality in your template you have to include the following code in your template (example should work with the default dokuwki template):

<?php   
if (!plugin_isdisabled("shorturl") && auth_quickaclcheck($ID >= AUTH_READ)){
    $shorturl = plugin_load('helper', 'shorturl');
    print $shorturl->shorturlPrintLink($ID);
}
?>

This prints a link “generate short url” when no mapping for the current page exists, and a link “short URL” when the mapping has been created.

Discussion

This is great! But I don't know How can I insert this in my template. Where I insert that source codes? Please show example by default template…
See above, this code works in the default template, you have to install version 2010-12-12 of the plugin.
Oh, Thanks very much! I can use simple url to post twitter! Thanks!



Integration in Template: "Bug"?

Thanks for the great plugin! Works like a charm.

To integrate it properly into the template I had to change the code.

Your code is:

<?php   
if (!plugin_isdisabled("shorturl") && auth_quickaclcheck($ID >= AUTH_READ)){
    $shorturl = plugin_load('helper', 'shorturl');
    print $shorturl->shorturlPrintLink($ID);
}
?>

and I think that, in the second line, one of the closing parenthesis must be after the “$ID”, like:

<?php   
if (!plugin_isdisabled("shorturl") && auth_quickaclcheck($ID) >= AUTH_READ){
    $shorturl = plugin_load('helper', 'shorturl');
    print $shorturl->shorturlPrintLink($ID);
}
?>

otherwise it's not working for me.

My code to integrate it into the “vector”-template (Print / Export Menu):

// So wird ein short-URL-Link ins Menü "Export" eingebaut. Wichtig: bei "$_vector_boxes["p-coll-print_export"]" muss der Text so angepasst werden, dass die ensprechende Box gewählt ist (also z.B. p-coll-print_export oder eben was anderes)!
// je nachdem in der Reihenfolge noch ändern, so dass es dort steht, wo man's will oder auch in eine andere Toolbox verschieben.
 
// Use this code to insert a short-URL-Link into the menu "Export". Important: use the right text in "$_vector_boxes["p-coll-print_export"]" so that the menu item is in the place you want it (e.g. p-coll-print_export or an other text)!
// You might want to change the place where it should stand or use another "box" (e.g. "Tools").
 
 
 
                 if (!plugin_isdisabled("shorturl") && auth_quickaclcheck($ID) >= AUTH_READ){
    $shorturl = plugin_load('helper', 'shorturl');
     $_vector_boxes["p-coll-print_export"]["xhtml"] .= "<li id=\"t-whatlinkshere\">". $shorturl->shorturlPrintLink($ID) ."</li>\n";
}

Thanks

chlwchlw

2013/08/29 07:28

Translations

plugin/shorturl.txt · Last modified: 2013/08/29 07:30 by chlw