Home › Forums › Back End › Homepage that changes headline copy and background image on Reload/Refresh. CODE ADDED, HELP! › Re: Homepage that changes headline copy and background image on Reload/Refresh. CODE ADDED, HELP!
Can you use straight JQ for this or does if have to be php ?
You have various options like random images with jquery titles pulled from the ‘title’ or ‘alt’ attributes..
I’m not really into php or much of a coder, but perhaps creating a array for each heading,image combo might work put into case switches. –> http://php.net/manual/en/control-structures.switch.php
$randomizer = rand(0,2); // random statement
switch($randomizer) { // returned value is loaded into the switch. The returned value loads the relevant data
case ($randomizer == '1'):
$title = 'Alpha dog';
$bg = '../img/dog1.jpg'
break;
case ($randomizer == '2'):
$title = 'Beta dog';
$bg = '../img/dog2.jpg'
break;
default:
$title = 'Default dog';
$bg = '../img/dog-default.jpg'
break;
}
echo '
'.$title.'
'
Something like that. I’m sure someone with a little more php expertise can help you out here.