Panel Widget: Content Viewer

A nifty little Kirby widget plugin that allows you to show a block of Kirbytext or Markdown content in Kirby’s panel. It is particularly useful for providing documentation for the website editors.

Get it over at https://github.com/CalebGrove/content-viewer

5 Likes

Thanks for sharing :slight_smile:.

1 Like

Thank you! I think I could use it as a base for a similar field with a different way to display information.

1 Like

Thank you for sharing your plugin!

I struggle a bit at the installing process:

Uh-oh, we can’t find the page with the content. Have you created one yet using the Content Viewer Widget template?

Can you explain that more precisely? How do I create one with the help of that widget blueprint?

Cheers

Andi,

I should probably provide a more detailed tutorial.

What you need to do is create a new page on the website. In the modal, select “Content Viewer Widget” as the template. Everything else (page name and path) is up to you.

Then, just add content to that page and it will appear in the widget!

I think the problem was that I restricted the available templates to something like this:

pages: true
  template:
    - mainpage

It did not appear in my list. So in order to get this working I needed remove the restriction, then add the readme page and then add it back again afterwards (ofc. I don’t want my clients to be able to create readme’s ^^).

That would do it. I’ll have to see if I can get Kirby to create the page when the plugin first runs in the background — that would solve this issue. Unfortunately, it may be awhile before I have time to dig into this.

I got a problem with kirbytext when I want to place the kirbytext documentation into the widget.

I basically copy & pasted the markdown of the official documentation. There the kirbytext is escaped by a \ like this:

(\link: http://wikipedia.org text: Wikipedia class: mylink)

However if I do this in my file the backslash \ will be displayed (which might cause confusion for the client) and if I remove the \ then the kirbytext will get parsed and be displayed in html :frowning: . How can I escape the kirbytext or disable the parser for this very file to display the proper documentation?

The Kirby site uses str_replace for this. You can use a Kirbytext post filter to do the same:

kirbytext::$post[] = function($kirbytext, $value) {
  return str_replace('(\\', '(', $value);
};

That’s how you did it :slight_smile:

Thank you it works perfectly.

I just pushed v1.2.0 of this plugin! Amongst a bunch of other changes, it now creates the page it needs on-demand, hides it from the website users, and provides a handy “edit” button for website administrators.

1 Like