Content & Templates

Installation

Plain Kit

https://herd.laravel.com/new/getkirby/plainkitarrow-up-right

PHP

  • Crash course in PHP

Folder Structure

  • index.php main PHP file

  • content source of truth, data, or db for file based system

  • site plugins, blueprints, themes

  • assets supplementary files for site

  • kirby CMS files. Update files here.

  • media optimized and managed by Kirby e.g. crop, optimize, etc.

Content Folder Structure

Why?

  • easy to create complex folder/file tree structures

  • folder content and structure should be able to exist and understand easily without the cms

  • Portable. Portable. Portability to take to ANY system. NO vendor lockin.

What?

  • content folder single source of truth

  • default folders - /content/error/error.txt default - /content/home/home.txt default - site.txt is the site object

  • Entry content is stored with the entry

Content Folders

  • Reference:

  • new custom content site path

    • /content/NameOfDirectory

    • picks up name of NameOfDirectory by default

    • /content/NameOfDirectory/NameOfDirectory.txt

  • Sub Folders

    • `/content/NameOfDirectory/SubDirectoryp;-['/]

    • /content/NameOfDirectory/SubDirectory.txt

    • EX:

      • create /content/projects

      • create /content/projects.txt

      • repeat for /content/team and /conent/team.txt

    • EX:

      • manually sort content folders

      • prepend folder numbers


Front Matter Fields

  • Front Matter

    • fieldName: values

    • ---- four dashes to separate fields

    • fields are flexible and are not required

    • content can have no, all, any combo of fields

  • global content can also be stored in the root content folder

  • Metadata can be stored in same folder

    • FileName.ext.txt is associated with the file

  • Sorting

    • preprend numbers, labels, ids, etc. to folder names


Main Template

Why?

  • static templates that load content dynamically

  • D.R.Y. principles of programming

  • Easily change website look and feel without changing content

  • Main reason why CMSs exist

How?

  • /templates/defaults.php

    • /templates/defaults.php everything is served from this default boilerplate

    • responsible for what gets sent to the browser

      • set HTML boilerplate here

    • EX:

      • output $site->title

  • $page object most important

    • see docs for this important object

    • $page->fieldName() outputs the field

  • $site object 2nd most important

    • see docs for this important object

    • $site->url()

    • $site->title()

  • css() loads CSS file via relative path

  • dynamically list navigation

    • default.php gets HTML boilerplate

    • PHP foreach( $site->children() as $item)

    • $item->url(), $item->title()

    • $item->url(), $item->title()->listed() to get numbered directories

Sub Templates

Why?

  • Custom templates for each content types e.g. blog, portfolio, etc.

  • Extend the default template

How?

  • List content from folders

  • If content FolderNamematches the site/templates file, it will load that file. E.g.

    • content: content/photos/photos.txt

    • template: site/templates/photos.php

    • templates can be shared with other types of content

  • list children of directory with $page->children() in forEach() loop


Entry Pages from Content

Why?

  • list sub content from within folders

How?


Snippets

Why?

  • D.R.Y. principles

How

  • create snippet in snippets/snippetName.php

  • template files include by snippet(snippetName)


Last updated