私はstackoverflowと他のいくつかのサイトを検索し、新しいコードの組み合わせを数時間試しましたが、あきらめました..私は2つのphpファイルを持っています.1つはgetimages.phpと呼ばれ、もう1つはmod_slidepluslight.phpと呼ばれます。 CMSとしてライトボックスでスライドショーモジュールを作成したので、.xmlファイルに設定されたモジュールパラメーターを介してJoomla内のフォルダーから画像を取得したいと考えています。私はこのコードを使用してこれを行いました:
$imagePath = $params->get('imagePath', 'banners');
この変数を宣言してコードで使用しようとしても、何もしません。
function returnimages($relPath = "/KVD/images/") {
$dirname = $_SERVER['DOCUMENT_ROOT'] . $relPath . $imagePath;
$imagePath は、/KVD/images/......./ の後、または現在の場所に追加する必要があります。getimages.php のコード全体は次のようになります。
Header("content-type: application/x-javascript");
$imagePath = $params->get('imagePath', 'banners/');
function returnimages($relPath = "/KVD/images/") {
$dirname = $_SERVER['DOCUMENT_ROOT'] . $relPath . $imagePath;
$files = array();
$curimage = 0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if (preg_match('/\.(jpg|jpeg|gif|png)$/', $file)){
print_r ('galleryarray['.$curimage.']="'. $relPath . $file .'";');
$curimage++;
}
}
closedir($handle);
}
return($files);
}
print 'var galleryarray=new Array();'; //Define array in JavaScript
returnimages() //Output the array elements containing the image file names
ありがとう、コーエン。