we_universal

Random header image on we_universal - we_universal

Random header image on we_universal

by EA117 » Thu Jul 30, 2020 6:19 pm

Combining the original proposed code from inventea.com with the $user->theme['theme_path'] to $user->style['style_path'] change as well as the "does not work with phpBB route-based URLs" fix, the proposed code for randomization on phpBB 3.2.x and phpBB 3.3.0 is:

10. How to add random header image?

Create a new directory called headers/ in the styles/we_universal/theme/ location. You should put all header images in the new directory. Now open includes/functions.php and find these existing lines:

Code: Select all

// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
Before those existing lines, add these additional lines:

Code: Select all

// Path to directory with header images (must contain trailing slash)
$inventea_images_path = "styles/" . rawurlencode($user->style['style_path']) . '/theme/headers/';

// Get list of images in directory
$inventea_images_list = array_diff(scandir( $phpbb_root_path . $inventea_images_path), array('.', '..'));

if (!empty($inventea_images_list))
{
	// Get random image name
	$inventea_random_image = $inventea_images_list[array_rand($inventea_images_list)];
}
Now also find this existing line:

Code: Select all

'SITE_LOGO_IMG'			=> $user->img('site_logo'),
After this existing line, add the following additional line:

Code: Select all

'INVENTIA_RANDOM_IMAGE' => (isset($inventea_random_image)) ? $web_path . $inventea_images_path . $inventea_random_image : '',
Next open styles/we_universal/template/overall_header.html and find:

Code: Select all

<div class="inventea-dashboard">
Replace with:

Code: Select all

<div class="inventea-dashboard" style="background-image: url({INVENTIA_RANDOM_IMAGE});">
That's it! Don't forget to upload images.
User avatar
EA117
Registered User
Posts: 1970
Joined: Wed Aug 15, 2018 3:23 am
Contact: