Creating a /random url

Something like this should work:

Your button:

  <a class="randumb" href="<?php echo url() . '/episode/random' ?>">random</a>

In your config.php

c::set('routes', array(
  array(
    'pattern' => 'episode/random',
    'action'  => function() {
    	$page = page('episode')->children('visible')->shuffle()->first();
     
      	go($page->url());
    }
  )
));
2 Likes