DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:shorturl

shorturl Plugin

Compatible with DokuWiki

Hrun

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

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

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with links, redirect, shorturls

Download and Installation

Search and install the plugin using the Extension Manager. 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 DokuWiki 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

chlw 2013/08/29 07:28

<?php // this will always print shorturl if current page exists.
if (!plugin_isdisabled("shorturl") && (auth_quickaclcheck($ID)>=AUTH_READ) 
     && ($INFO['exists'])) {
    $shorturl = plugin_load('helper', 'shorturl');
    print DOKU_URL.$shorturl->autoGenerateShortUrl($ID);
  }
?>

S.C. Yoo 2015-05-30 15:47

Translations

plugin/shorturl.txt · Last modified: 2023-12-15 12:34 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki