To add a random greeting to your homepage for example, add a comma-separated field with greetings to content/home/home.txt. You also need to create a specific template for the homepage by adding site/templates/home.php. Use the code from home.php as a starting point for your homepage template.
-
-
Save dleatherman/2853199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php snippet('header') ?> | |
<?php snippet('menu') ?> | |
<?php snippet('submenu') ?> | |
<?php | |
// get the entire string and | |
// split it into an array by comma | |
$tokens = str::split($page->greeting()); | |
// shuffle all tokens | |
shuffle($tokens); | |
// get the first one | |
$greeting = $tokens[0]; | |
?> | |
<h1><?php echo $greeting ?></h1> | |
<h2><?php echo $page->title() ?></h2> | |
<?php echo kirbytext($page->text()) ?> | |
<?php snippet('footer') ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: Welcome to this nice website | |
---- | |
Text: Some Text | |
---- | |
Greeting: Hello, Hi, Hey, Howdy, Aloha | |
---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment