Disable page versioning in permalink

8

Hi Admin,


How can I disable page versioning in WackoWiki so that the permalink does not appear to change when a page is updated?


Thank you.

Comments

  1. Re: Disable page versioning in WackoWiki

    Got it, the solution is to edit action/hashid.php and change the default value from:

    if (!isset($version)) $version = 1;

    to:

    if (!isset($version)) $version = 0;


    ChatGPT helped me find this solution :D.
    • coffe1nk
    • 06/24/2026 18:05 edited
  2. Re: Disable page versioning in permalink

    What you wanna achieve? Disable permalink, want that permalink always point to the recent version and not to the current version? Or do you want disable versioning at all. Please clarify.
    • WikiAdmin
    • 06/25/2026 08:02 edited
  3. Re: Disable page versioning in WackoWiki

    Hi Admin,

    I’m using WackoWiki mainly for personal notes. I update pages quite often, and sometimes I also rename them.

    Because of that, I need a permalink that stays the same even after the page is updated or renamed. Otherwise, I have to keep updating the links manually in my other notes or external references whenever the generated permalink changes.

    regards,
  4. Re: Disable page versioning in permalink

    Change the permalink so it always link to the page and not to the recent version of the page by setting version=0. The permalink uses the hashid action.
    Description:
    	Creates a permalink to the current version of the page or simply to the page itself.
    
    Usage:
    	{{hashid}}
    
    Options:
    	[version=0|1]
    		0 - link to the page
    		1 - link to the current page version (default)	


    [1] Theme footer
    In your theme footer you can set the version parameter to 0.

    theme/default/appearance/footer.php
    // permalink
    $tpl->perma_link = $this->action('hashid', ['version' => 0]);	


    [2] Action
    When using the action in a page:

    action/hashid.php
    {{hashid version=0}}
    • WikiAdmin
    • 06/25/2026 08:15 edited
  5. Re: Disable page versioning in permalink

    Should work in 6.0.37 the same way regarding using version=0.

    Good to hear that 6.0.37 works, it was a blind back-port – my testing environment for PHP 7.4 was already gone.

    WackoWiki 6.1.0
    • section edit support
    • thumbnail creation
    • global string find-and-replace action

    WackoWiki 6.2.0
    • SQLite support
    • extended table syntax

    WackoWiki 6.3.0
    • totally revamped WikiEdit (test here)
    • Composer usage
    • dark mode
    • modern syntax highlighting with Phiki
  6. Re: Disable page versioning in permalink

    I created a hashlink action. It uses the hashid permalink and automatically displays the page title.

    <?php
    
    if (!defined('IN_WACKO'))
    {
        exit;
    }
    
    /*
        USAGE:
        {{hashlink id="QmdteTNEaOo"}}
        {{hashlink id="QmdteTNEaOo" text="Custom Title"}}
    
        Output:
        <a href="/QmdteTNEaOo">Page Title</a>
    */
    
    if (empty($id))
    {
        return;
    }
    
    $id = trim($id);
    
    try
    {
        $hashids = new \Hashids\Hashids($this->db->hashid_seed);
        $ids = $hashids->decode($id);
    }
    catch (\Throwable $e)
    {
        echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
        return;
    }
    
    if (!is_array($ids) || count($ids) < 3)
    {
        echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
        return;
    }
    
    $page_id    = (int) $ids[0];
    $version_id    = (int) $ids[1];
    $check        = (int) $ids[2];
    
    sscanf(hash('sha1', $page_id . $this->db->hashid_seed . $version_id), '%7x', $expected_check);
    
    if ($check !== (int) $expected_check)
    {
        echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
        return;
    }
    
    // get page title
    $page = $this->db->load_single(
        "SELECT page_id, tag, title " .
        "FROM " . $this->prefix . "page " .
        "WHERE page_id = " . $page_id . " " .
        "LIMIT 1"
    );
    
    if (!$page)
    {
        echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
        return;
    }
    
    // link text
    if (!empty($text))
    {
        $link_text = $text;
    }
    else if (!empty($page['title']))
    {
        $link_text = $page['title'];
    }
    else
    {
        $link_text = $page['tag'];
    }
    
    // permalink URL
    $url = $this->href('', $id, '', '', '', false);
    
    echo '<a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '">' .
        htmlspecialchars($link_text, ENT_QUOTES, 'UTF-8') .
        '</a>';
    • coffe1nk
    • 06/28/2026 06:44 edited
  7. Re: Disable page versioning in permalink

    Actions are dynamic and then you can use the page tag and the link() function for href once you queried the page table, except the case you wanna explicitly a hash link for copy and paste.

    Additionally you can create a template for the action, which makes it easier to set escapes and modify HTML.
    $tpl->fail_id = $id;
    $tpl->href = $this->href('', $id, '', '', '', false);
    $tpl->text = $link_text;
    $tpl->title = $page['title'] ?: $page['tag'];	

    action/template/hashlink.tpl
    [ === main === ]
    	[= fail _ =
    		<span class="error">[ ' id | e ' ]</sapn>
    	=]
    	<a href="[ ' href | e attr ' ]" title="[ ' title | e attr ' ]">[ ' text | e ' ]</a>	
    • WikiAdmin
    • 06/28/2026 08:35 edited
Log in or create an account to post a comment.