TOPIC:

Random Background in kaiser theme 3 years 4 months ago #199133

  • Topic Author
  • nem13es
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 26
  • Thanks: 0
Is there anyway to make the background image randomize in kaiser theme, like we do in this web www.pinturasmoran.com ?

thks.

Please Log in or Create an account to join the conversation.

Random Background in kaiser theme 3 years 4 months ago #199168

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hello there,

Sure it can be done.

1) Go to \joomla\templates\kaiser\less\style.less and around line 117 you will see #ct-body class and comment out all the background properties so they look like this :
#ct-body{
    width: 100%;
    background-position: center;
 // background: url(../images/bg_site_01.png) repeat left, -moz-linear-gradient(top, @bodybackground 0%, @bodybackground 100%);
//  background: url(../images/bg_site_01.png) repeat left, -webkit-gradient(linear, left top, left bottom, color-stop(0%,@bodybackground), color-stop(100%,@bodybackground));
//  background: url(../images/bg_site_01.png) repeat left, -webkit-linear-gradient(top, @bodybackground 0%,@bodybackground 100%);
//  background: url(../images/bg_site_01.png) repeat left, -o-linear-gradient(top, @bodybackground 0%,@bodybackground 100%);
//  background: url(../images/bg_site_01.png) repeat left, -ms-linear-gradient(top, @bodybackground 0%,@bodybackground 100%);
//  background: url(../images/bg_site_01.png) repeat left, linear-gradient(top, @bodybackground 0%,@bodybackground 100%);
}

2) Navigate to your \templates\kaiser\images and inside images folder add your background images

3) Find and open index.php file in this location \joomla\templates\kaiser

4) Add this code right after your opening <head> tag :
<?php
$bg = array('01.jpg', '02.png'); // array of filenames
$i = rand(0, count($bg)-1); // generate random number of the array
$selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>    

<style type="text/css">
#ct-body{
background-image: url(templates/kaiser/images/<?php echo $selectedBg; ?>) ;
}    
</style>

NOTE : you need to replace filenames in code above so they match your background filenames- ('01.jpg', '02.png');
$bg = array('01.jpg', '02.png'); // array of filenames, change these filenames so they reflect your image files.

Let us know if this helped.

Regards,
Mario

Please Log in or Create an account to join the conversation.

Last edit: Post by MarioPuco.

Random Background in kaiser theme 3 years 4 months ago #199178

  • Topic Author
  • nem13es
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 26
  • Thanks: 0
i´ve comment the class and add the code to index.php, and now the bg is changing only in home page, in the rest of pages the bg still wite.

www.pinturasmoran.com/nueva

this the new site.

Please Log in or Create an account to join the conversation.

Random Background in kaiser theme 3 years 4 months ago #199192

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hi,

Try changing this part in your CSS script :

From :
background-image: url(templates/kaiser/images/<?php echo $selectedBg; ?>) ;

To:
background-image: url(http://pinturasmoran.com/nueva/templates/kaiser/images/<?php echo $selectedBg; ?>) ;


Let us know if this worked.

Regards,
Mario

Please Log in or Create an account to join the conversation.

Random Background in kaiser theme 3 years 4 months ago #199323

  • Topic Author
  • nem13es
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 26
  • Thanks: 0
It works perfectly by changing the path.

Thanks.

Please Log in or Create an account to join the conversation.

Random Background in kaiser theme 3 years 4 months ago #199338

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hi,

That's great :)

Let us know if you have any other questions.

Regards,
Mario

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.051 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!