Custom Styling & Content Based on Param

I’ve been trying to figure out how to create custom titles based on the param that’s in the url, but I’m at a loss for how to achieve this. I saw this article which I was able to replicate after some trial and error, but it wasn’t exactly what I was looking for.

What I’m trying to achieve is something where I can set different HTML and CSS based on the Category that’s being filtered using the “select” param. I have 4 categories (Design, Tech, Productivity, and Misc). The example below is completely wrong, but I’m adding it hoping it illustrates what I’m trying to accomplish. Any help would be appreciated!

<?php if($topic = param('design')) ?>
    // html here
<?php elseif($topic = param('tech')) ?>
    // html here
<?php elseif($topic = param('productivity')) ?>
    // html here
<?php elseif($topic = param('misc')) ?>
    // html here
<?php endif ?>

If your param is called select, then you have to use this parameter name (with design etc. as the possible values).

if ( 'design' === param('select') ) {
 // do something
}

Or whatever your parameter name.

Hi, I’m still confused. Sorry, I’m not an engineer… :sweat_smile:

  1. How would I string this with multiple if statements? When I do this on my site, everything breaks.
  2. How would I insert HTML/CSS into the PHP statement? Wouldn’t I have to close it before the // do something part?

Here’s what I’m trying to do:


    <?php if ('design' = param('topic')): ?>
						
        <p>This page is about Design</p>
						
    <?php elseif ('tech' = param('topic')): ?>
					
        <p>This page is about Tech</p>
						
    <?php endif ?>

Sorry, my bad:

  <?php if ('design' === param('topic')): ?>

This works perfectly! Thanks!!