Skip to content

Instantly share code, notes, and snippets.

@vipickering
Created November 24, 2012 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vipickering/4139171 to your computer and use it in GitHub Desktop.
Save vipickering/4139171 to your computer and use it in GitHub Desktop.
PHP: Kirby Post Type Detection
<?php foreach($page->children()->visible() as $article): ?>
<article>
<?php if($article->template() == 'article.text'): ?>
<!-- put the HTML for the text post here -->
<div>text post</div>
<?php elseif($article->template() == 'article.video'): ?>
<!-- put the HTML for the video post here -->
<div>video post</div>
<?php elseif($article->template() == 'article.image'): ?>
<!-- put the HTML for the image post here -->
<div>image post</div>
<?php elseif($article->template() == 'article.link'): ?>
<!-- put the HTML for the link post here -->
<div>link post</div>
<?php elseif($article->template() == 'article.quote'): ?>
<!-- put the HTML for the quote post here -->
<div>quote post</div>
<?php endif ?>
</article>
<?php endforeach ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment