Posted in site bugs
1
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
30
This Month
363
This Year
0

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 snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

Join me on Substack if you want me to send you a collection of the things i have done or found or read for the week. Or follow me on twitter if you prefer, i dont post much but i probably should!

❤👩‍💻🕹

Random Quote
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better. You won't believe what you can accomplish by attempting the impossible with the courage to repeatedly fail better.
Unknown