Posted in site bugs
9106
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
208
This Month
1209
This Year
2695

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
When i was a little kid, I was really scared of the dark. But then I came to understand, dark just means the absence of photons in the visible wavelength -- 400 to 700 nanometers. Then i thought, well, its really silly to be afraid of a lack of photons. Then i wasn't afraid of the dark anymore after that.
Elon Musk
Random CSS Property

range

When defining custom counter styles, the range descriptor lets the author specify a range of counter values over which the style is applied. If a counter value is outside the specified range, then the fallback style will be used to construct the representation of that marker.
range (@counter-style) css reference