【发布时间】:2013-12-17 21:11:44
【问题描述】:
我的drupal主体有这个代码,带有php代码文本格式:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<img id="thisImg" alt="img" src="http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/ads1.jpg"/>
<script type="text/javascript">
var myImage = new Array();
ctr = 0;
$(function(){
<?php
$log_directory = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/';
foreach(glob($log_directory.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory2 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery2/';
foreach(glob($log_directory2.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory3 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery3/';
foreach(glob($log_directory3.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory4 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery4/';
foreach(glob($log_directory4.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory5 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery5/';
foreach(glob($log_directory5.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory6 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery6/';
foreach(glob($log_directory6.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory7 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery7/';
foreach(glob($log_directory7.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory8 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery8/';
foreach(glob($log_directory8.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
console.log(myImage);
var thisId=0;
window.setInterval(function(){
$('#thisImg').attr('src',myImage[thisId]);
thisId++; //increment data array id
if (thisId==ctr) thisId=0; //repeat from start
},2000);
});
</script>
当我尝试单独在 php 文件中运行此代码时。
/var/www/unplay/trytoplay.php
它工作正常。 但是当我尝试用drupal body 编写它时。它没有用。 然后我尝试运行我的控制台,它说:
Uncaught TypeError: Object [object Object] has no method 'tinyNav' main-menu.jsmxywgd:85
Uncaught TypeError: Object [object Object] has no method 'cycle'
我尝试安装 tinyNav,但没有任何反应。 感谢您的帮助。
【问题讨论】:
标签: javascript php jquery drupal drupal-7