- Postagens: 58
- Obrigados Recebidos: 0
- Fórum
- /
- Suporte Joomla
- /
- Templates
- /
- Joomla 1.5
- /
- [RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
[RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
- walisson3d
-
Autor do Tópico
- Offline
- JCB! Junior
-
Menos
Mais
15 anos 10 meses atrás #21063
por walisson3d
walisson3d created the topic: [RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
Bom dia pessoal,
o template ja_purity troca as imagens do header a cada atualização da página. A troca a cada atualização da página é feita da seguinte forma:
1. No arquivo index.php do template tem um código que chama a função para pegar uma imagem aleatória. O código é este:
<div id="ja-headerwrap">
<div id="ja-header" class="clearfix" style="background: url(<?php echo $tmpTools->templateurl(); ?>/images/header/<?php echo $tmpTools->getRandomImage(dirname(__FILE__).DS.'images/header'); ?>) no-repeat top <?php if($this->direction == 'rtl') echo 'left'; else echo 'right';?>;">
2. A função getRandomImage está no arquivo ja_templatetools.php. Ela executa o seguinte código:
function getRandomImage ($img_folder) {
$imglist=array();
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (preg_match("#gif#i", $file) || preg_match("#jpg#i", $file) || preg_match("#png#i", $file))
$imglist[] = $file;
}
closedir($imgs->handle);
if(!count($imglist)) return '';
//generate a random number between 0 and the number of images
$random = mt_rand(0, count($imglist)-1);
$image = $imglist[$random];
return $image;
}
Minha dúvida é: como fazer esta troca também a cada 5 segundos (pode ser mais ou menos tempo) se o visitante não atualizar a página? Teria que ser feito através de um javascript? Se fosse em php seria tranquilo, mas não entendo nada de javascript.
Alguém pode me ajudar? Agradeço antecipadamente.
o template ja_purity troca as imagens do header a cada atualização da página. A troca a cada atualização da página é feita da seguinte forma:
1. No arquivo index.php do template tem um código que chama a função para pegar uma imagem aleatória. O código é este:
<div id="ja-headerwrap">
<div id="ja-header" class="clearfix" style="background: url(<?php echo $tmpTools->templateurl(); ?>/images/header/<?php echo $tmpTools->getRandomImage(dirname(__FILE__).DS.'images/header'); ?>) no-repeat top <?php if($this->direction == 'rtl') echo 'left'; else echo 'right';?>;">
2. A função getRandomImage está no arquivo ja_templatetools.php. Ela executa o seguinte código:
function getRandomImage ($img_folder) {
$imglist=array();
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (preg_match("#gif#i", $file) || preg_match("#jpg#i", $file) || preg_match("#png#i", $file))
$imglist[] = $file;
}
closedir($imgs->handle);
if(!count($imglist)) return '';
//generate a random number between 0 and the number of images
$random = mt_rand(0, count($imglist)-1);
$image = $imglist[$random];
return $image;
}
Minha dúvida é: como fazer esta troca também a cada 5 segundos (pode ser mais ou menos tempo) se o visitante não atualizar a página? Teria que ser feito através de um javascript? Se fosse em php seria tranquilo, mas não entendo nada de javascript.
Alguém pode me ajudar? Agradeço antecipadamente.
Please Entrar ou Registrar to join the conversation.
- walisson3d
-
Autor do Tópico
- Offline
- JCB! Junior
-
Menos
Mais
- Postagens: 58
- Obrigados Recebidos: 0
15 anos 10 meses atrás #21475
por walisson3d
walisson3d replied the topic: Re: Ja_purity - Trocar header a cada 5 segundos
Consegui resolver o problema utilizando o módulo "RokSlideshow". Coloquei o módulo para aparecer em todos os menus e também na posição correta no template, que no ja_purity é a user4. Basta configurar no módulo a pasta que contém as imagens e o tempo em milesegundos. Problema resolvido!!!!
Curiosidade: para quem quiser tentar por javascript, o código abaixo pode ser usado, com as devidas modificações:
<script language="JavaScript">
var how_many_ads = 2;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="";
url=" www.criarsites.com ";
alt="Dicas para Webmasters";
banner=" www.criarsites.com/wp-content/uploads/2008/05/criar-sites.gif ";
width="468";
height="60";
}
if (ad==2) {
txt="";
url=" www.criarblog.com ";
alt="Dicas para Criar Blogs";
banner=" www.criarsites.com/wp-content/uploads/2008/05/criar-blog.gif ";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_parent\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</script>
Agradeço a todos que visualizaram o tópico e espero que seja útil futuramente para os colegas. <!-- s:P --><img src="{SMILIES_PATH}/icon_razz.gif" alt="
" title="Legal" /><!-- s:P -->
Curiosidade: para quem quiser tentar por javascript, o código abaixo pode ser usado, com as devidas modificações:
<script language="JavaScript">
var how_many_ads = 2;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="";
url=" www.criarsites.com ";
alt="Dicas para Webmasters";
banner=" www.criarsites.com/wp-content/uploads/2008/05/criar-sites.gif ";
width="468";
height="60";
}
if (ad==2) {
txt="";
url=" www.criarblog.com ";
alt="Dicas para Criar Blogs";
banner=" www.criarsites.com/wp-content/uploads/2008/05/criar-blog.gif ";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_parent\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</script>
Agradeço a todos que visualizaram o tópico e espero que seja útil futuramente para os colegas. <!-- s:P --><img src="{SMILIES_PATH}/icon_razz.gif" alt="

Please Entrar ou Registrar to join the conversation.
- João Alberto
-
- Offline
- JCB! Novato
-
Menos
Mais
- Postagens: 1
- Obrigados Recebidos: 0
15 anos 8 meses atrás #23618
por João Alberto
João Alberto replied the topic: Re: [RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
Valeu! Fiz minha inscrição somente para agradecer pelo script java. Já o PHP não consegui implementar...
Muito Obrigado!
Muito Obrigado!
Please Entrar ou Registrar to join the conversation.
- thunder
-
- Offline
- JCB! Novato
-
Menos
Mais
- Postagens: 7
- Obrigados Recebidos: 0
14 anos 7 meses atrás #45051
por thunder
<!-- w --><a class="postlink" href=" www.streetbaixada.com " onclick="window.open(this.href);return false;"> www.streetbaixada.com </a><!-- w -->
<!-- w --><a class="postlink" href=" www.facebook.com/streetbaixada " onclick="window.open(this.href);return...
thunder replied the topic: Re: [RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
Galera to apanhado pq não consigo implementar esse código ao meu template, uso o blancoynegro se alguem puder me ajudar agradeço... <!-- s:? --><img src="{SMILIES_PATH}/icon_e_confused.gif" alt="
" title="Confuso" /><!-- s:? -->

<!-- w --><a class="postlink" href=" www.streetbaixada.com " onclick="window.open(this.href);return false;"> www.streetbaixada.com </a><!-- w -->
<!-- w --><a class="postlink" href=" www.facebook.com/streetbaixada " onclick="window.open(this.href);return...
Please Entrar ou Registrar to join the conversation.
- Rafael Viana de Castro
-
- Offline
- JCB! Junior
-
Menos
Mais
- Postagens: 98
- Obrigados Recebidos: 0
14 anos 6 meses atrás #45316
por Rafael Viana de Castro
Rafael Viana de Castro replied the topic: Re: [RESOLVIDO] Ja_purity - Trocar header a cada 5 segundos
Para fazer a troca de imagens, pode-se utilizar também um arquivo flash.swf junto com mu modulo de carregamento de flash posicionando onde desejar.
Please Entrar ou Registrar to join the conversation.