PHP集合 - 刷新或页面更改时的代码复制 [英] PHP Collection - Code Duplication upon refresh or page change
问题描述
我已经创建了一些自定义代码(下面的代码中的第287-309行)它是313-345的重复功能,但有一些更改。
尽管由于某些原因,该功能可以很好地起作用,因为页面的更改或刷新会复制页面底部的集合。
如果我将行287-309移动到第347行这不会发生。我假设我在这里创建了一些循环,或者我没有正确关闭PHP?
任何帮助将非常感谢。
代码:
<?php
include../include/ db.php中;
include../include/authenticate.php;
包含../include/general.php;
包含../include/resource_functions.php;
包含../include/collections_functions.php;
hook(homeheader);
include../include/header.php;
if(!hook(replacehome)){
if(!hook(replaceaceslideshow)){
#在配置的$ homeanim_folder中。
$ dir = dirname(__ FILE__)。 /../。 $ homeanim_folder;
$ filecount = 0;
$ checksum = 0; #制作校验和,这是图像URL中所有图像文件的总和,用于强制刷新,如果有任何图像发生变化。
$ d = scandir($ dir);
sort($ d,SORT_NUMERIC);
$ reslinks = array();
foreach($ d as $ f){
if(preg_match(/ [0-9] + \。(jpg)/,$ f))
{
$ filecount ++;
$ checksum + = filesize($ dir。/。$ f);
$ linkfile = substr($ f,0,(strlen($ f)-4))。 。文本;
$ reslinks [$ filecount] =;
if(file_exists(../。$ homeanim_folder。/$ linkfile))
{
$ linkref = file_get_contents(../。$ homeanim_folder。 $ linkfile);
$ linkaccess = get_resource_access($ linkref);
if(($ linkaccess!==)&&(($ linkaccess == 0)||($ linkaccess == 1))){$ reslinks [$ filecount] = $ baseurl。 /pages/view.php?ref=。 $ linkref;}
}
}
}
$ homeimages = $ filecount;
if($ filecount> 1){#只有在多个图像时才添加Javascript。
?>
< script type =text / javascript>
var num_photos =<?php echo $ homeimages?> ;; //< ----照片数量(/images/slideshow?.jpg)
var photo_delay = 5; //< ---- photo delay in seconds
var link = new Array();
<?php
$ l = 1;
foreach($ reslinks as $ reslink)
{
echolink [。 $ l。 ] = \。$ reslink。\;;
$ l ++;
}
?>
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;} / *照片幻灯片不再可用(AJAX页面移动)* /
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 ='<?php echo $ baseurl。/$ homeanim_folder?> /+ next_photo +.jpg?checksum =<?php echo $ checksum?>'; if(linktarget!=''){jQuery('#slideshowlink')。attr('href',linktarget);} else { ( '#slideshowlink')removeAttr( 'href' 属性);},1000);
flip = 1;
}
else
{
// image1.style.visibility ='visible';
//Effect.Appear(image1);
jQuery('#image1')。fadeIn(1000)
window.setTimeout(image2.style.background ='url(<?php echo $ baseurl。/$ homeanim_folder?> ; /+ next_photo +.jpg?checksum =<?php echo $ checksum?>)'; if(linktarget!=''){jQuery('#slideshowlink')。attr('href',linktarget) ;}其他{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()
{
/ *清除所有旧计时器* /
ClearTimers();
timers.push(window.setTimeout(nextPhoto(),1000 * photo_delay));
}
);
< / script>
<?php}?>
< div class =HomePicturePanel
<?php if(isset($ home_slideshow_width)){
echo style = \;
$ slide_width = $ home_slideshow_width + 0;
echowidth:。(string)$ slide_width ;
echo\;
}
?>>
< a id =slideshowlink
<?php
$ linkurl =#;
if(file_exists(../。$ homeanim_folder。/1.txt))
{
$ linkres = file_get_contents(../。$ homeanim_folder。的1.txt);
$ linkaccess = get_resource_access($ linkres);
if(($ linkaccess!==)&&(($ linkaccess == 0)||($ linkaccess == 1))){$ linkurl = $ baseurl。 /pages/view.php?ref=。 $ linkres;}
echohref = \$ linkurl\;
}
?>
\>
< div class =HomePicturePanelINid ='photoholder'style =
<?php
if(isset($ home_slideshow_height)){
echo height:。(string)$ home_slideshow_height。px; ;
}
?>
background-image:url('<?php echo $ baseurl。/$ homeanim_folder?> /1.jpg ?checksum =<?php echo $ checksum?>');>
< img src ='<?php echo $ baseurl。 /。 $ homeanim_folder?> /2.jpg?checksum =<?php echo $ checksum?>'alt =''id ='image1'style =display:none;<?php
if(isset ($ home_slideshow_width)){
echowidth:。$ home_slideshow_width。px; ;
}
if(isset($ home_slideshow_height)){
echoheight:。$ home_slideshow_height。px; ;
}
?>>
< / div>
< / a>
< div class =PanelShadow>< / div>
< / div>
<?php}#结束钩子替换显示
?>
<?php if(checkperm(s)){
hook(homebeforepanels);
?>
<?php if($ home_themeheaders&& $ enable_themes){?>
< div class =HomePanel>< div class =HomePanelIN>
< h2< a onClick =return CentralSpaceLoad(this,true); href =<?php echo $ baseurl_short?> pages / themes.php><?php echo $ lang [themes]?>< / a>< / h2>
<?php echo text(themes)?>
< br /> < br />
< select style =width:140px;的onChange = CentralSpaceLoad(THIS.VALUE,TRUE); >
< option value =><?php echo $ lang [select]?>< / option>
<?php
$ headers = get_theme_headers();
($ n = 0; $ n {
?>
< option value =<?php echo $ baseurl_short?> pages / themes.php?header =<?php echo urlencode($ headers [$ n])?>& ?php echo i18n_get_translated(str_replace(*,,$ headers [$ n]))?>< / option>
<?php
}
?>
< / select>
< br />&>& nbsp;< a href =<?php echo $ baseurl_short?> pages / themes.phponClick =return CentralSpaceLoad(this,true) ;><?php echo $ lang [viewall]?>< / a>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php if($ home_themes&& $ enable_themes){?>
< div class =HomePanel>< div class =HomePanelINtopA>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / themes.phponClick =return CentralSpaceLoad(this,true) style =color:#ffffff><?php echo $ lang [themes]?>< / a>< / div>
< div class =HomePanelINtopText><?php echo text(themes)?>< / div>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php if($ home_mycollections&&?checkperm(b)&&#$ userrequestmode!= 2&&#$ userrequestmode!= 3){?
< div class =HomePanel>< div class =HomePanelINtopB>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / collection_manage.phponClick =return CentralSpaceLoad(this,true)风格= 颜色:#FFFFFF; > <?php echo $ lang [mycollections]?>< / a>< / div>
< div class =HomePanelINtopText><?php echo text(mycollections)?>< / div>
< / div>
< div class =PanelShadow>
< / div>
< / div>
<?php}?>
<?php if($ home_advancedsearch){?>
< div class =HomePanel>< div class =HomePanelINtopC>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / search_advanced.phponClick =return CentralSpaceLoad(this,true)风格= 颜色:#FFFFFF; > <?php echo $ lang [advancedsearch]?>< / a>< / div>
< div class =HomePanelIntopText><?php echo text(advancedsearch)?>< / div>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php if($ home_mycontributions&&(checker(d)||(checkperm(c)&& checkperm(e0))){ ?>
< div class =HomePanel>< div class =HomePanelINtopD>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / contribut.phponClick =return CentralSpaceLoad(this,true) style =color:#ffffff><?php echo $ lang [mycontributions]?>< / a>< / div>
< div class =HomePanelIntopText><?php echo text(mycontributions)?>< / div>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php if($ home_helpadvice){?>
< div class =HomePanel>< div class =HomePanelINtopE>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / help.phponClick =return CentralSpaceLoad(this,true) style =color:#ffffff><?php echo $ lang [helpandadvice]?>< / a>< / div>
< div class =HomePanelIntopText><?php echo text(help)?>< / div>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php if($ home_themes&& $ enable_themes){?>
< div class =HomePanel>< div class =HomePanelIntopIntro>
< div class =HomePanelIntopHeader>< a href =<?php echo $ baseurl_short?> pages / themes.phponClick =return CentralSpaceLoad(this,true) style =color:#ffffff><?php echo text(welcometitle)?>< / a>< / div>
< div class =HomePanelINtopText><?php echo text(welcometext)?>< / div>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php}?>
<?php
/ * ------------可自定义的主页面板-------- ($ n = 0; $ n {
$ n ++)
{
if(!hook(panelperm)){
?>
< div class =HomePanel>< div class =HomePanelIN<?php if($ custom_home_panels [$ n] [text] ==){?> style = min-height:0;<?php}?>>
< h2< a href =<?php echo $ custom_home_panels [$ n] [link]?> <?php if(isset($ custom_home_panels [$ n] [additional])){echo $ custom_home_panels [$ n] [additional];}?>> <?php echo i18n_get_translated($ custom_home_panels [$ n] [title])?>< / a>< / h2>
<?php echo i18n_get_translated($ custom_home_panels [$ n] [text])?>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php
} // end hook'panelperm'
}
}
?>
<! - 这是第287行请参考问题 - >
<?php
if(!hook(EditorsPick)):
/ * ------------提升到主页的集合--- ---------------- * /
$ home_collectionsx = get_home_page_promoted_collectionsx(16);
foreach($ home_collectionsx as $ home_collectionx)
{
?>
< div class =EditorsPick>
< div class =HomePanel>< div class =HomePanelINtopEditors>
< div class =HomePanelINtopHeader>编辑者选择< / div>
< div class =HomePanelINtopText>这是资产空间...< / div>的编辑者选择
< div class =EditorsPicImage>< div style =padding-top:<?php echo floor((155- $ home_collectionx [thumb_height])/ 2)?& margin-top:-24px; margin-bottom:-15px;>
< a href =<?php echo $ baseurl_short?> pages / search.php?search =!collection<?php echo $ home_collectionx [ref]?> onClick =return CentralSpaceLoad(this,true);>< img class =ImageBordersrc =<?php echo get_resource_path($ home_collectionx [home_page_image],false,thm,false)?> ; width =<?php echo $ home_collectionx [thumb_width]?> height =<?php echo $ home_collectionx [thumb_height]?> />< / DIV>
< / div>< / div>
< / div>
< / div>
< / div>
<?php
}
endif; #end hook homefeaturedcol
?>
<! - 这是第309行请参考问题>
<! - 这是LINE 313请参考问题 - >
<?php
if(!hook(homefeaturedcol)):
/ * ------------提升到主页的集合--- ---------------- * /
$ home_collections = get_home_page_promoted_collections(16);
foreach($ home_collections as $ home_collection)
{
?>
< div class =ResourceOfTheDay>< / div>
< div class =HomePanel HomePanelPromoted>< div class =HomePanelIN HomePanelPromotedIN>
< div class =MyCollectionsHighlite>< / div>
< div class =HomePanelPromotedImageWrap>
< div style =padding-top:<?php echo floor((155- $ home_collection [thumb_height])/ 2)?& top:-24px; margin-bottom:-15px;>
< a href =<?php echo $ baseurl_short?> pages / search.php?search =!collection<?php echo $ home_collection [ref]?> onClick =return CentralSpaceLoad(this,true);>< img class =ImageBordersrc =<?php echo get_resource_path($ home_collection [home_page_image],false,thm,false)?> ; width =<?php echo $ home_collection [thumb_width]?> height =<?php echo $ home_collection [thumb_height]?> />< / DIV>
< / div>
< p style =font-size:14px; font-weight:bold>< a href =<?php echo $ baseurl_short?> pages / search.php? search =!collection<?php echo $ home_collection [ref]?> onClick =return CentralSpaceLoad(this,true);><?php echo i18n_get_translated($ home_collection [home_page_text])?>< / a>< / p>
< p style =font-size:12px; font-weight:normal>< a href =<?php echo $ baseurl_short?> pages / search.php? search =!collection<?php echo $ home_collection [ref]?> onClick =return CentralSpaceLoad(this,true);>点击查看此集合< / a>< / p>
< / div>
< div class =PanelShadow>< / div>
< / div>
<?php
}
endif; #end hook homefeaturedcol
?>
<! - 这是第345行请参考问题>
<! - 这是LINE 347请参考问题>
< div class =clearerleft>< / div>
<?php}
} // ReplaceHome钩子的结尾
include../include/footer.php ;
?>
从你上面的评论我会说这一行是责备:
if(!hook(homefeaturedcol)):
pre>
我假设这是运行,以及上面的新代码,当它不是首页
您可能还想看看您的HTML结构
I have created some custom code (lines 287-309 in the code below)It is a duplicate function of 313-345 but with a few changes.
Although the function works perfectly well for some reason the page upon change or refresh duplicate the collection at the bottom of the page.
If I move lines 287-309 to line 347 onwards this does not happen. I'm assuming I a creating some sort of loop here or am I not closing the PHP correctly?
Any help would be hugely appreciated.
The Code:
<?php include "../include/db.php"; include "../include/authenticate.php"; include "../include/general.php"; include "../include/resource_functions.php"; include "../include/collections_functions.php"; hook("homeheader"); include "../include/header.php"; if (!hook("replacehome")) { if (!hook("replaceslideshow")) { # Count the files in the configured $homeanim_folder. $dir = dirname(__FILE__) . "/../" . $homeanim_folder; $filecount = 0; $checksum=0; # Work out a checksum which is the total of all the image files in bytes - used in image URLs to force a refresh if any of the images change. $d = scandir($dir); sort($d, SORT_NUMERIC); $reslinks=array(); foreach ($d as $f) { if(preg_match("/[0-9]+\.(jpg)/",$f)) { $filecount++; $checksum+=filesize($dir . "/" . $f); $linkfile=substr($f,0,(strlen($f)-4)) . ".txt"; $reslinks[$filecount]=""; if(file_exists("../" . $homeanim_folder . "/" . $linkfile)) { $linkref=file_get_contents("../" . $homeanim_folder . "/" . $linkfile); $linkaccess = get_resource_access($linkref); if (($linkaccess!=="") && (($linkaccess==0) || ($linkaccess==1))){$reslinks[$filecount]=$baseurl . "/pages/view.php?ref=" . $linkref;} } } } $homeimages=$filecount; if ($filecount>1) { # Only add Javascript if more than one image. ?> <script type="text/javascript"> var num_photos=<?php echo $homeimages?>; // <---- number of photos (/images/slideshow?.jpg) var photo_delay=5; // <---- photo delay in seconds var link = new Array(); <?php $l=1; foreach ($reslinks as $reslink) { echo "link[" . $l . "]=\"" . $reslink . "\";"; $l++; } ?> 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='<?php echo $baseurl . "/" . $homeanim_folder?>/" + next_photo + ".jpg?checksum=<?php echo $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(<?php echo $baseurl . "/" . $homeanim_folder?>/" + next_photo + ".jpg?checksum=<?php echo $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)); } ); </script> <?php } ?> <div class="HomePicturePanel" <?php if (isset($home_slideshow_width)) { echo "style=\""; $slide_width = $home_slideshow_width + 0; echo"width:" . (string)$slide_width ."px; "; echo "\" "; } ?>> <a id="slideshowlink" <?php $linkurl="#"; if(file_exists("../" . $homeanim_folder . "/1.txt")) { $linkres=file_get_contents("../" . $homeanim_folder . "/1.txt"); $linkaccess = get_resource_access($linkres); if (($linkaccess!=="") && (($linkaccess==0) || ($linkaccess==1))) {$linkurl=$baseurl . "/pages/view.php?ref=" . $linkres;} echo "href=\"" . $linkurl ."\" "; } ?> \> <div class="HomePicturePanelIN" id='photoholder' style=" <?php if (isset($home_slideshow_height)){ echo"height:" . (string)$home_slideshow_height ."px; "; } ?> background-image:url('<?php echo $baseurl . "/" . $homeanim_folder?>/1.jpg?checksum=<?php echo $checksum ?>');"> <img src='<?php echo $baseurl . "/" . $homeanim_folder?>/2.jpg?checksum=<?php echo $checksum ?>' alt='' id='image1' style="display:none;<?php if (isset($home_slideshow_width)){ echo"width:" . $home_slideshow_width ."px; "; } if (isset($home_slideshow_height)){ echo"height:" . $home_slideshow_height ."px; "; } ?>"> </div> </a> <div class="PanelShadow"></div> </div> <?php } # End of hook replaceslideshow ?> <?php if (checkperm("s")) { hook("homebeforepanels"); ?> <?php if ($home_themeheaders && $enable_themes) { ?> <div class="HomePanel"><div class="HomePanelIN"> <h2><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php"><?php echo $lang["themes"]?></a></h2> <?php echo text("themes")?> <br /> <br /> <select style="width:140px;" onChange="CentralSpaceLoad(this.value,true);"> <option value=""><?php echo $lang["select"] ?></option> <?php $headers=get_theme_headers(); for ($n=0;$n<count($headers);$n++) { ?> <option value="<?php echo $baseurl_short?>pages/themes.php?header=<?php echo urlencode($headers[$n])?>"><?php echo i18n_get_translated(str_replace("*","",$headers[$n]))?></option> <?php } ?> </select> <br />> <a href="<?php echo $baseurl_short?>pages/themes.php" onClick="return CentralSpaceLoad(this,true);"><?php echo $lang["viewall"] ?></a> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php if ($home_themes && $enable_themes) { ?> <div class="HomePanel"><div class="HomePanelINtopA"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/themes.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"><?php echo $lang["themes"]?></a></div> <div class="HomePanelINtopText"><?php echo text("themes")?></div> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php if ($home_mycollections && !checkperm("b") && $userrequestmode!=2 && $userrequestmode!=3) { ?> <div class="HomePanel"><div class="HomePanelINtopB"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/collection_manage.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"> <?php echo $lang["mycollections"]?></a></div> <div class="HomePanelINtopText"><?php echo text("mycollections")?></div> </div> <div class="PanelShadow"> </div> </div> <?php } ?> <?php if ($home_advancedsearch) { ?> <div class="HomePanel"><div class="HomePanelINtopC"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/search_advanced.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"> <?php echo $lang["advancedsearch"]?></a></div> <div class="HomePanelINtopText"><?php echo text("advancedsearch")?></div> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php if ($home_mycontributions && (checkperm("d") || (checkperm("c") && checkperm("e0")))) { ?> <div class="HomePanel"><div class="HomePanelINtopD"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/contribute.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"><?php echo $lang["mycontributions"]?></a></div> <div class="HomePanelINtopText"><?php echo text("mycontributions")?></div> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php if ($home_helpadvice) { ?> <div class="HomePanel"><div class="HomePanelINtopE"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/help.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"><?php echo $lang["helpandadvice"]?></a></div> <div class="HomePanelINtopText"><?php echo text("help")?></div> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php if ($home_themes && $enable_themes) { ?> <div class="HomePanel"><div class="HomePanelINtopIntro"> <div class="HomePanelINtopHeader"><a href="<?php echo $baseurl_short?>pages/themes.php" onClick="return CentralSpaceLoad(this,true);" style="color:#ffffff;"><?php echo text("welcometitle")?></a></div> <div class="HomePanelINtopText"><?php echo text("welcometext")?></div> </div> <div class="PanelShadow"></div> </div> <?php } ?> <?php /* ------------ Customisable home page panels ------------------- */ if (isset($custom_home_panels)) { for ($n=0;$n<count($custom_home_panels);$n++) { if (!hook("panelperm")) { ?> <div class="HomePanel"><div class="HomePanelIN" <?php if ($custom_home_panels[$n]["text"]=="") {?>style="min-height:0;"<?php } ?>> <h2><a href="<?php echo $custom_home_panels[$n]["link"] ?>" <?php if (isset($custom_home_panels[$n]["additional"])){ echo $custom_home_panels[$n]["additional"];} ?>> <?php echo i18n_get_translated($custom_home_panels[$n]["title"]) ?></a></h2> <?php echo i18n_get_translated($custom_home_panels[$n]["text"]) ?> </div> <div class="PanelShadow"></div> </div> <?php } // end hook 'panelperm' } } ?> <!-- THIS IS LINE 287 please refer to question --> <?php if(!hook("EditorsPick")): /* ------------ Collections promoted to the home page ------------------- */ $home_collectionsx=get_home_page_promoted_collectionsx(16); foreach ($home_collectionsx as $home_collectionx) { ?> <div class="EditorsPick"> <div class="HomePanel"><div class="HomePanelINtopEditors"> <div class="HomePanelINtopHeader">Editors Pick</div> <div class="HomePanelINtopText">This is the editors pick of Asset Space...</div> <div class="EditorsPicImage"><div style="padding-top:<?php echo floor((155-$home_collectionx["thumb_height"])/2) ?>px; margin-top: -24px; margin-bottom: -15px;"> <a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collectionx["ref"] ?>" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="<?php echo get_resource_path($home_collectionx["home_page_image"],false,"thm",false) ?>" width="<?php echo $home_collectionx["thumb_width"] ?>" height=" <?php echo $home_collectionx["thumb_height"] ?>" /></div> </div></div> </div> </div> </div> <?php } endif; # end hook homefeaturedcol ?> <!-- THIS IS LINE 309 please refer to question --> <!-- THIS IS LINE 313 please refer to question --> <?php if(!hook("homefeaturedcol")): /* ------------ Collections promoted to the home page ------------------- */ $home_collections=get_home_page_promoted_collections(16); foreach ($home_collections as $home_collection) { ?> <div class="ResourceOfTheDay"></div> <div class="HomePanel HomePanelPromoted"><div class="HomePanelIN HomePanelPromotedIN"> <div class="MyCollectionsHighlite"></div> <div class="HomePanelPromotedImageWrap"> <div style="padding-top:<?php echo floor((155-$home_collection["thumb_height"])/2) ?>px; margin-top: -24px; margin-bottom: -15px;"> <a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collection["ref"] ?>" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="<?php echo get_resource_path($home_collection["home_page_image"],false,"thm",false) ?>" width="<?php echo $home_collection["thumb_width"] ?>" height="<?php echo $home_collection["thumb_height"] ?>" /></div> </div> <p style="font-size:14px; font-weight:bold"><a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collection["ref"] ?>" onClick="return CentralSpaceLoad(this,true);"><?php echo i18n_get_translated($home_collection["home_page_text"]) ?></a></p> <p style="font-size:12px; font-weight:normal"><a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collection["ref"] ?>" onClick="return CentralSpaceLoad(this,true);">Click to view this collection</a></p> </div> <div class="PanelShadow"></div> </div> <?php } endif; # end hook homefeaturedcol ?> <!-- THIS IS LINE 345 please refer to question --> <!-- THIS IS LINE 347 please refer to question --> <div class="clearerleft"></div> <?php } } // End of ReplaceHome hook include "../include/footer.php"; ?>
解决方案From your comment above I would say this line is to blame:
if(!hook("homefeaturedcol")):
I'm assuming that this is running as well as your new code above it when it's not the homepage
You may also want to have a look at your HTML structure
这篇关于PHP集合 - 刷新或页面更改时的代码复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!