Jump to content

Colocar Header Aleatório


jotix
 Share

Recommended Posts

Ando a tentar no meu blog, o Eurito, colocar um header aleatório.

De forma que, quando alguém visitar o Eurito, seja exibido um header aleatório.

Para isso, já tenho o script, que exibe aleatoriamente um header, quando a página é carregada:

A página php do header, para exibir a imagem do header, tem uma secção, em que vai chamar uma função de style.css

<div class="top">

Indo ao ficheiro style.css, a função top, tem a seguinte descrição:

.top {
height:223px;
margin-top:0px;
background:url(images/header.jpg);
background-repeat:no-repeat;

Mas ao mudar essa parte para:

.top {
height:223px;
margin-top:0px;
background:url(http://eurito.net/wp-content/themes/nap/imagem-header.php);
background-repeat:no-repeat;

Não funciona! O que está errado?

?

Link to comment
Share on other sites

Boas,

Faz o seguinte no CSS :

.top {

        height:223px;

        margin-top:0px;

        background-position: top left;

        background-repeat:no-repeat;

}

E no php :

<div class="top" style="background-image:url(http://eurito.net/wp-content/themes/nap/imagem-header.php);"></div>

Se não funcionar, em vez de usar uma div usa a tag img

Link to comment
Share on other sites

Boas.

Provavelmente não funciona porque tens "imagem-header.php", não devia ser png, ou gif, ou jpeg, etc ?

Não, porque a imagem é escolhida aleatoriamente pelo ficheiro imagem-header.php 😛

EDIT: jotix, o ficheiro PHP faz imprime as tags <img> ou uma imagem?

PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum.

Link to comment
Share on other sites

Antes de mais obrigado a todos pelas respostas  😛

Então, o codigo do ficheiro php, que mostra aleatoriamente as imagens é:

<?php
// generates some random content

// start an array with some text strings...

$blah[] = '
<img src="http://i700.photobucket.com/albums/ww5/eurito/top3-1.jpg" border="0">
';

$blah[] = '
<img src="http://i700.photobucket.com/albums/ww5/eurito/top2.jpg" border="0">
';

$blah[] = '
<img src="http://i700.photobucket.com/albums/ww5/eurito/top.jpg" border="0">
';

// seed php random number generator
// http://www.php.net/srand
srand ((float) microtime() * 10000000);

// print a random $blah
// http://www.php.net/array_rand
print $blah[array_rand($blah)];

?>;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.