Posted in site bugs
7415
3:36 am, October 14, 2021
 

Changing the default hero image based on the category name [not yet done]

This is more of a todo item, at the moment the hero image uses the same image for every post unless a hero is specified for each, i would also like to set the default image per category so if the post or code is in a category it loads that default but the hero can still override that image per post. 

So if the category == "site bugs" it sets the hero image to site_bugs.png or something similar. 

Hero Widget

This is generated by the function $page_content .= $class->hero_widget($t_uid = $class->uid, $t_class = $p2); 

Well on further inspection i have already built in a per category hero image, so that is good, just need to add some more options here.

PHP

<?php      /* rather than just returning blank, why not add a placeholder or default image here instead, depending on the class type. 
    code background for code items, not sure for content. */
      if(!$show_home_hero_content) { // dont overwrite a linked hero image.
        if($t_class == "code") {
          // matrix style background.. ;)
          $show_home_hero_content = true;
          $hero_image_url = "https://i.imgur.com/hP23gMk.jpg";
        }
        if($t_class == "content") {
          $show_home_hero_content = true;
          $hero_image_url = "https://i.imgur.com/5czkBNv.jpg";
        }
        if( ($t_class == "content") && ($t_class_loaded->category == "rs3") ) { // default rs3 category background.
          $show_home_hero_content = true;
          $hero_image_url = "https://i.imgur.com/M2QR7bN.jpg";
        }
    } ?>

That was easier than i thought as i had already done the work it seems. Its funny how you write code and then forget about it, i should probably document it more. 

PHP

        if($t_class_loaded->category == "react") {
          $show_home_hero_content = true;
          $hero_image_url = "https://i.imgur.com/aff9ett.jpg";
        }

 

View Statistics
This Week
125
This Month
524
This Year
1004

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
Our brains are wired to find things we are looking for - if your always cynical or waiting for things to go wrong, then your life will reflect that. On the other hand, having a positive outlook on life will bring you joy and provide you with inspiration when you least expect it ☀️🍉🌴
Unknown
Random CSS Property

<color>

The <color> CSS data type represents a color. A <color> may also include an alpha-channel transparency value, indicating how the color should composite with its background.
<color> css reference