Add PHP to views

From release 0.9.9, PHP can mostly be avoided in views.
If you need conditional data test, have a look at the chapter Conditions with tags.

// returns the current year
<?php echo date('Y'); ?>

Conditional PHP

Because the PHP code is executed after the Ionize tag parsing, the tags values can be tested.

<?php if ('<ion:page:title />' == 'About' ) :?>

   <p>This content is displayed if the title of the page is "About"</p>

<?php endif ;?>

Passing data from one tag to one tag attribute

<?php
 
  // Get the title of the page
  $page_title = '<ion:page:get key="title" />';

?>

<ion:page:articles>

  <!-- For each article, we display the page title as prefix -->
  <?php

    echo '<ion:article:title prefix="'.$page_title.' : " />';

  ?>

</ion:page:articles>