Compatibility of old blog articles

Hello,
I am currently working on a new blog. My challenge is to integrate the blog articles from our old blog (running on Kirby 2.4.1). However, some functionalities do not work there… I would be very happy about your help! :slight_smile:

1. Linking files in the content folder: we used to link individual files (for example a PDF) in the textareas in the panel with the following markup, which does not work in the new blog.
(link: content/blog/20100218-my-first-blog-article/some_file.pdf text: link-text).
I have found that I can link the file using the following path: (link: blog/my-first-blog-article/some_file.pdf text: link-text) But is there a way to make the first path work?

2. Open link in new tab: “popup: yes” vs. “target: _blank” Is it true that the first attribute is no longer supported in the current Kirby version?

3. Listing of articles: For some reason, our old blog articles are listed in the following way: “20100218-my-first-blog-article”. So with a hyphen instead of an underscore after the date: 20100218_my-first-blog-article. The articles are therefore not displayed as “listed”. Is there a solution for this (besides renaming all articles …)?

Many thanks in advance and best regards
Jana

For a summary on how to migrate from Kirby 2 to Kirby 3, there’s this article here:

Specifically, let’s start with 3:

  1. Create a backup of your content
  2. Create a file in your webroot upgrade.php:
    <?php
    require __DIR__ . '/kirby/bootstrap.php';
    Kirby\Cms\System::upgradeContent(__DIR__ . '/content');
    
  3. Run it via your server http://localhost/upgrade.php
  4. Delete your upgrade.php file

This should rename all of your folders to the new convention.

It’s probably the most forward looking to update your content to use the new path. But I guess you could also write a route as a plugin that responds to requests that start with “/content”:

site/plugins/k2compat/index.php:

<?php 

use Kirby\Cms\App as Kirby;

Kirby::plugin('kirby2/compat', [
    'routes' => [
        [
            'pattern' => 'content/(:all)',
            'action'  => function ($path) {
                // replace sorting numbers dash with underscore
                $path = preg_replace('/\/(\d+)-/', '/$1_', "/$path");

                // check if the file exists
                if (file_exists(kirby()->root('content') . $path) === true) {
                    // remove sorting numbers from the path
                    $path = preg_replace('/\/\d+_([^\/]+)/', '/$1', $path);
                    return go($path);
                }

                return false;
            }
        ]
    ]
]);

Yes, that’s correct. I think the easiest would be to open your content folder in a coding IDE (e.g VS Code), and do a “search & replace” over all .txt files. Alternatively you could think to rewrite the (link:) kirbytag to support a popup attribute; you would probably start by copying the existing tag into a plugin and then modifying it.