← Tutoriais

Random image script

Lida 7622 vezes

Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Boas a todos.

Andei a pesquisar no fórum e nenhum dos scripts me serviu.

Eu quero algo para mudar uma imagem na parte inicial da minha loja (cubecart) http://iphoneportugal.com/forum .

Já tentei 3 scripts, alguém me ajuda aqui?  :obrigado:
Offline

SFCMiguel 
Membro
Mensagens 187 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 100 Posts

Offline

goodsound 
Membro
Mensagens 2485 Gostos 0
Troféus totais: 31
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3

Queres algo para que sempre que a página seja carregada apareça uma imagem aleatória?
Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

linkinboy, como disse eu pesquisei. Encontrei isso mas olha o resultado:

http://www.iphoneportugal.com/loja/

Com php não penso que resulte. Não haverá em html?
Offline

-RJ- 
Membro
Mensagens 1188 Gostos 0
Troféus totais: 30
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Pus essa mas quero que rodem mais......
Offline

anjo2 
Membro
Mensagens 3020 Gostos 0
Troféus totais: 31
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Offline

Emanuel Santos 
Elite
Mensagens 848 Gostos 2
Feedback +25

Troféus totais: 25
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 4 Level 3 Level 2 Level 1

<img src="imagem<?php echo rand(1,3); ?>.jpg" />

imagem1.jpg
imagem2.jpg
imagem3.jpg
..
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

<img src="imagem<?php echo rand(1,3); ?>.jpg" />

imagem1.jpg
imagem2.jpg
imagem3.jpg
..

:o Nunca tinha pensado nisso
Offline

-RJ- 
Membro
Mensagens 1188 Gostos 0
Troféus totais: 30
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

<img src="imagem<?php echo rand(1,3); ?>.jpg" />

imagem1.jpg
imagem2.jpg
imagem3.jpg
..

Sem dúvida a melhor solução em PHP pelo menos... ;)
Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

<img src="imagem<?php echo rand(1,3); ?>.jpg" />

imagem1.jpg
imagem2.jpg
imagem3.jpg
..

Não funciona, vai ver. Já está lá o código!

thomato, pelas tuas palavras neste fórum, pareces um entendido sobre muita coisa. Escreve-me um código por favor meu caro.

Dá para por códigos html no cubecart (editor de texto) penso que php não funcione...
Offline

Emanuel Santos 
Elite
Mensagens 848 Gostos 2
Feedback +25

Troféus totais: 25
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 4 Level 3 Level 2 Level 1

No HTML não funciona. Experimenta colocar na template

Esta a pressupor que te safavas minimamente
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Hel.Souza, antes de mais, não sou grande entendido. Penso que sou. É um defeito que tenho.

Em relação ao script, http://pixelfm.org/random/ ... Funciona perfeitamente o que o Tom Strong deu.
Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

É assim, o cubecart é das coisas mais estranhas que já vi!! Nos ficheiros do template apenas tenho do tipo*.tpl!!!! Só ficheiros template??' Porque raio isto é assim? Deste modo não sei o que editar. Ok , há um ficheiro inc.inc.index.php onde no footer aparece a cena do "powered by", este devia poder editar mas não posso! O cubecart descarta logo um erro "file edited without permition"....

Eu sei que php não funciona a menos que seja um ficheiro php, mas o que acho estranho é que o index é php. Por isso o conteúdo do documento da primeira página devia processar php. Ao menos eu pensava assim tom strong. Ao que parece enganei-me e revelei essa info aqui, depois de me dares o código. Percebeste Tom Strong?
Offline

-RJ- 
Membro
Mensagens 1188 Gostos 0
Troféus totais: 30
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

E JS funciona?

Adaptei o código do random em php para js:

Código: [Seleccione]
<script type="text/javascript">
var arr = new Array(3)
arr[1] = "<img src='http://images.google.pt/intl/pt-PT_ALL/images/images_hp.gif' />"
arr[2] = "exemplo 2"
arr[3] = "exemplo 3"
var rand = Math.ceil(3*Math.random())
document.write(arr[rand]);
</script>