Get URL parameter

Hello everyone,

I’m a beginner with Kirby and I am stuck on a simple thing, which drives me crazy !

I just want to create a simple URL parameter. To get this I’m using this kind of link:

<a href='<?= $page->url()?>?view=grid'>

which load the url localhost:8888/plainkit-master/projects/?view=grid

No problem for the moment. However when I do this:

<?  if (isset($_GET['view']) ) && $_GET['view']=='grid') {  ?>	
	
 MY HTML WHEN GRID PARAMETERS

<?
}

else { ?>

MY HTML WHEN GRID PARAMETERS IS NOT SET

<? } ?>

It always give me the else parameters.

Is there a Kirby way of doing that ? Or Am I missing a rookie mistake ? :sweat_smile:

Thanks a lot!

Welcome to the forum :wave:

You are missing proper PHP tags. In addition, you can use Kirby’s get() helper and I would definitely recommend avoiding the use of curly braces when in mixing HTML and PHP so that we end up with with this nicely formatted code :wink: :

<?php  if ( get('view') === 'grid' ) : ?>	
	
    <! --MY HTML WHEN GRID PARAMETERS -->

<?php else : ?>

    <!-- MY HTML WHEN GRID PARAMETERS IS NOT SET -->

<?php endif; ?>
1 Like

Ok it is that simple… haha

Thank you very much !!