Coleção PHP – Duplicação de código após atualização ou alteração de página

Eu criei algum código personalizado (linhas 287-309 no código abaixo) É uma function duplicada de 313-345, mas com algumas mudanças.

Embora a function funcione perfeitamente bem, por algum motivo, a página após a alteração ou atualização duplicar a coleção na parte inferior da página.

Se eu mover as linhas 287-309 para a linha 347 em diante, isso não acontece. Estou supondo que eu crie algum tipo de loop aqui ou não estou fechando o PHP corretamente?

Qualquer ajuda seria grandemente agradecida.

O código:

1) { # Only add Javascript if more than one image. ?>  var num_photos=; // <---- number of photos (/images/slideshow?.jpg) var photo_delay=5; // <---- photo delay in seconds var link = new Array();  var cur_photo=2; var last_photo=1; var next_photo=2; flip=1; var image1=0; var image2=0; function nextPhoto() { if (!document.getElementById('image1')) {return false;} /* Photo slideshow no longer available (AJAX page move) */ if (cur_photo==num_photos) {next_photo=1;} else {next_photo=cur_photo+1;} image1 = document.getElementById("image1"); image2 = document.getElementById("photoholder"); sslink = document.getElementById("slideshowlink"); linktarget=link[cur_photo]; if (flip==0) { // image1.style.visibility='hidden'; //Effect.Fade(image1); jQuery('#image1').fadeOut(1000) window.setTimeout("image1.src='https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change//" + next_photo + ".jpg?checksum=';if(linktarget!=''){jQuery('#slideshowlink').attr('href',linktarget);}else{jQuery('#slideshowlink').removeAttr('href');}",1000); flip=1; } else { // image1.style.visibility='visible'; //Effect.Appear(image1); jQuery('#image1').fadeIn(1000) window.setTimeout("image2.style.background='url(https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change//" + next_photo + ".jpg?checksum=)';if(linktarget!=''){jQuery('#slideshowlink').attr('href',linktarget);}else{jQuery('#slideshowlink').removeAttr('href');}",1000); flip=0; } last_photo=cur_photo; cur_photo=next_photo; timers.push(window.setTimeout("nextPhoto()", 1000 * photo_delay)); } jQuery(document).ready( function () { /* Clear all old timers */ ClearTimers(); timers.push(window.setTimeout("nextPhoto()", 1000 * photo_delay)); } );   <div class="HomePicturePanel" > <a id="slideshowlink"  \> <div class="HomePicturePanelIN" id='photoholder' style="  background-image:url('https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change//1.jpg?checksum=');"> <img src='https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change//2.jpg?checksum=' alt='' id='image1' style="display:none;"> 

<a onClick="return CentralSpaceLoad(this,true);" href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/themes.php">



<?php $headers=get_theme_headers(); for ($n=0;$n <option value="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/themes.php?header=">
> <a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/themes.php" onClick="return CentralSpaceLoad(this,true);">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/themes.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/collection_manage.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/search_advanced.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/contribute.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/help.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/themes.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;">
<?php /* ------------ Customisable home page panels ------------------- */ if (isset($custom_home_panels)) { for ($n=0;$n
<div class="HomePanelIN" style="min-height:0;">

<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/" >

Editors Pick
This is the editors pick of Asset Space...
<div style="padding-top:px; margin-top: -24px; margin-bottom: -15px;"> <a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/search.php?search=!collection" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/" width="" height=" " />
<div style="padding-top:px; margin-top: -24px; margin-bottom: -15px;"> <a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/search.php?search=!collection" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/" width="" height="" />

<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/search.php?search=!collection" onClick="return CentralSpaceLoad(this,true);">

<a href="https://stackoverflow.com/questions/17879023/php-collection-code-duplication-upon-refresh-or-page-change/pages/search.php?search=!collection" onClick="return CentralSpaceLoad(this,true);">Click to view this collection

Do seu comentário acima, eu diria que essa linha é a culpa:

 if(!hook("homefeaturedcol")): 

Estou assumindo que isso está sendo executado, bem como seu novo código acima dele, quando não é a página inicial

Você também pode querer dar uma olhada em sua estrutura HTML