我正在编写一个辅助函数来共享视图的负载,因为它可以在某些页面上被多次调用。唯一的问题是它有时只能工作,但所有相关文件都在那里,并且 Code Igniter 不会生成错误消息。这是调用该函数的视图:
<div id="newProducts" class="floatLeft">
<div class="titleBar">
<h4>New Product Arrivals</h4>
</div>
<?php foreach($newProducts as $product) :
loadshareProductPreview($product);
endforeach; ?>
这是到目前为止的功能:
function loadShareProductPreview($product)
{
$time = microtime(true);
if($time % 3 == 0)
{
include("/home/client/library/application/views/widgets/productPreview.php");
}
elseif($time % 3 == 1)
{
include("/home/client/library/application/views/widgets/productPreviewLS1.php");
}
elseif($time % 3 == 2)
{
include("/home/client/library/application/views/widgets/productPreviewLS2.php");
}
}
关于如何让它一直加载的任何想法?