PHPackages                             flokosiol/viewmode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. flokosiol/viewmode

ActiveKirby-plugin[Templating &amp; Views](/categories/templating)

flokosiol/viewmode
==================

Kirby plugin to render a page in different view modes

1.0.1(1y ago)32MITPHP

Since Feb 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/flokosiol/kirby-viewmode)[ Packagist](https://packagist.org/packages/flokosiol/viewmode)[ Fund](https://www.paypal.me/flokosiol)[ RSS](/packages/flokosiol-viewmode/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Kirby View Mode
===============

[](#kirby-view-mode)

[![Version](https://camo.githubusercontent.com/f320321296127a37e6f092f464e978644977cd9e1503f75b815655116d36b8d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d312e302e312d626c75652e737667)](https://camo.githubusercontent.com/f320321296127a37e6f092f464e978644977cd9e1503f75b815655116d36b8d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d312e302e312d626c75652e737667) [![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667) [![Kirby](https://camo.githubusercontent.com/4963ea95e5c23c8b79ba35cb9894d4b590e635603b5bb3d3af114a38a5760210/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b697262792d342b2d6630633637342e737667)](https://camo.githubusercontent.com/4963ea95e5c23c8b79ba35cb9894d4b590e635603b5bb3d3af114a38a5760210/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b697262792d342b2d6630633637342e737667)

With this plugin for [Kirby CMS](http://getkirby.com) you can display pages in different view modes. If you like to know mor eabout this concept please check out [this article on my website](https://flokosiol.de/articles/kirby-content-representations-custom-view-modes).

⚙️ Requirements
---------------

[](#️-requirements)

- Kirby CMS, Version **4+**

💰 Commercial Usage
------------------

[](#-commercial-usage)

This plugin is **free** but if you use it in a commercial project please consider to [make a donation](https://www.paypal.me/flokosiol).

🛠️ Installation
---------------

[](#️-installation)

### Composer

[](#composer)

It is recommended to install the plugin via Composer:

```
composer require flokosiol/viewmode
```

### Download

[](#download)

Alternatively you can download and extract this repository, rename the folder to `viewmode` and drop it into the plugins folder of your Kirby installation. You should end up with a folder structure like this:

```
site/plugins/viewmode/

```

### Git Submodule

[](#git-submodule)

If you prefer git submodules, this ist your command:

```
git submodule add https://github.com/flokosiol/kirby-viewmode.git site/plugins/viewmode
```

🧑‍💻 Usage
---------

[](#‍-usage)

### 1. View Mode Templates

[](#1-view-mode-templates)

This plugin is based on [content representations](https://getkirby.com/docs/guide/templates/content-representations). If you want to add a view mode to one of your page types you need to add a template to your `templates` folder like you do for content representations:

```
site/templates/mypagetype.myviewmode.php

```

The dafault template for the page type should already exists next to it.

```
site/templates/mypagetype.php

```

Inside your view mode template you can add the template code you want to use for the page when it's rendered in this particular view mode – just like you do in a normale page template or a snippet.

Like every other content representation you can make use of [controllers](https://getkirby.com/docs/guide/templates/content-representations#representation-controllers) to simplify your template code.

### 2. Using the view mode

[](#2-using-the-view-mode)

To render a page in the declared view mode add this to your template code …

```
