1

私はjoomlaを使用してサイトをやっています。モジュールJXTCVirtuemartProductWallをインストールしました。ただし、このモジュールは表示されず、「警告:174行目のZ:\ home \ megapolis.loc \ www \ modules \ mod_jxtc_vmwall \ tmpl \ default_parse.phpのforeach()に無効な引数が指定されました」というエラーが表示されます。このエラーの解決にご協力ください。これがdefault_parse.phpファイルです

// Get product params
$product = array('min_order_level' => 0, 'max_order_level' => 0);
$item_params = explode('|', $item->product_params);
foreach($item_params as $aux){
$aux = explode('=',$aux);
if (isset ($aux[1]))
    $aux[1] = str_replace('"', '', $aux[1]);
if ( isset($aux[0]) && isset ($aux[1]) && ((int)$aux[1] > 0) )
    $product[$aux[0]] = $aux[1];
}

// Get Parent data if necessary
if (((!$item->file_url_thumb && !$item->file_url) || (!$item->cid || !$item->product_s_desc || !$item->product_desc || !$item->product_availability)) && $item->parentid) {
$query = 'SELECT vmi.file_url_thumb, vmi.file_url, vmpc.virtuemart_category_id AS cid, vmpb.product_s_desc, vmcb.category_name,'.
        ' vmcb.category_description, vmpb.product_desc, vmp.product_availability FROM #__virtuemart_products AS vmp' .
        ' LEFT JOIN #__virtuemart_products_' . VMLANG . ' AS vmpb ON vmp.virtuemart_product_id = vmpb.virtuemart_product_id' .
        ' LEFT JOIN #__virtuemart_product_categories AS vmpc ON vmp.virtuemart_product_id = vmpc.virtuemart_product_id' .
        ' LEFT JOIN #__virtuemart_categories AS vmc ON (vmpc.virtuemart_category_id = vmc.virtuemart_category_id AND vmc.published = 1)' .
        ' LEFT JOIN #__virtuemart_categories_' . VMLANG . ' AS vmcb ON (vmc.virtuemart_category_id = vmcb.virtuemart_category_id)' .
        ' LEFT JOIN #__virtuemart_product_medias AS vmpi ON (vmp.virtuemart_product_id = vmpi.virtuemart_product_id AND vmpi.ordering < 2)' .
        ' LEFT JOIN #__virtuemart_medias AS vmi ON vmpi.virtuemart_media_id = vmi.virtuemart_media_id WHERE' .
        ' vmp.virtuemart_product_id = ' . $item->parentid . ' AND vmp.published = 1';

$db->setQuery($query);
$aux = $db->loadObject();

if (!$item->product_availability)
    $item->product_availability = $aux->product_availability;

if (!$item->product_desc)
    $item->product_desc = $aux->product_desc;

if (!$item->product_s_desc)
    $item->product_s_desc = $aux->product_s_desc;

if (!$item->file_url_thumb)
    $item->file_url_thumb = $aux->file_url_thumb;

if (!$item->file_url)
    $item->file_url = $aux->file_url;

if (!$item->cid){
    $item->category_description = $aux->category_description;
    $item->category_name = $aux->category_name;
    $item->cid = $aux->cid;
   }
}

// Product url
$producturl = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $item->id . '&virtuemart_category_id=' . $item->cid . $itemID);

// Category url
$categoryurl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $item->cid . $itemID);

// Manufacturer url
$manufacturerurl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $item->virtuemart_manufacturer_id . $itemID);

// Product availability
$product_availability_url = JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $item->product_availability;
$product_availability = JHTML::image($product_availability_url, $item->product_availability, array('class' => 'availability'));
//$product_availability = '<img src="' . $product_availability_url . '" alt="' . $item->product_availability . '" />';

// Category description
$cat_desc = strip_tags($item->category_description);
if (!empty($desclen))
$cat_desc = Jstring::trim(Jstring::substr($cat_desc, 0, $desclen)) . '...';

// Product description
$desc = strip_tags($item->product_desc);
if (!empty($desclen))
$desc = Jstring::trim(Jstring::substr($desc, 0, $desclen)) . '...';

// Product image
$imageurl = isset($item->file_url) ? $item->file_url : 'No picture';
$image = '<img src="' . $imageurl . '" alt="' . $item->product_name . '" />';
$image2 = '<img src="' . $imageurl . '" alt="' . $item->product_name . '"' .     $image_height . $image_width . ' />';

// Product thumbmnail
$thumb_url = isset($item->file_url_thumb) ? $item->file_url_thumb : 'No picture';
$thumb = '<img src="' . $thumb_url . '" alt="' . $item->product_name . '" />';

// Product rating
$maxrating = VmConfig::get('vm_maximum_rating_scale', 5);
$rating = empty($item->rating) ? JText::_('COM_VIRTUEMART_RATING') . ' ' .     JText::_('COM_VIRTUEMART_UNRATED') : JText::_('COM_VIRTUEMART_RATING') .     round($item->rating, 2) . '/' . $maxrating;

$itemhtml = str_replace('{category_name}', $item->category_name, $itemhtml);
$itemhtml = str_replace('{raw_category_description}', $item->category_description,     $itemhtml);
$itemhtml = str_replace('{category_description}', $cat_desc, $itemhtml);
$itemhtml = str_replace('{product_flypage}', $producturl, $itemhtml);
$itemhtml = str_replace('{product_url}', $item->product_url, $itemhtml);
$itemhtml = str_replace('{product_sku}', $item->product_sku, $itemhtml);
$itemhtml = str_replace('{product_name}', $item->product_name, $itemhtml);
$itemhtml = str_replace('{raw_description}', $item->product_desc, $itemhtml);
$itemhtml = str_replace('{description}', $desc, $itemhtml);
$itemhtml = str_replace('{manufacturer_name}', $item->mf_name, $itemhtml);
$itemhtml = str_replace('{manufacturer_url}', $manufacturerurl, $itemhtml);

$itemhtml = str_replace('{product_adate}', date($date_format, $item->available_date),     $itemhtml);
while (($ini = Jstring::strpos($itemhtml, "{product_adate")) !== false) {
$fin = Jstring::strpos($itemhtml, "}", $ini);
$filter = Jstring::substr($itemhtml, $ini, $fin - $ini + 1);
list($null, $fmt) = explode(' ', Jstring::substr($filter, 1, -1));
$val = date(Jstring::trim($fmt), $item->available_date);
$itemhtml = str_replace($filter, $val, $itemhtml);
}

$itemhtml = str_replace('{product_availability}', $product_availability, $itemhtml);
$itemhtml = str_replace('{product_availability_url}', $product_availability_url,     $itemhtml);

$itemhtml = str_replace('{product_cdate}', date($date_format, $item->created_on),     $itemhtml);
while (($ini = Jstring::strpos($itemhtml, "{product_cdate")) !== false) {
$fin = Jstring::strpos($itemhtml, "}", $ini);
$filter = Jstring::substr($itemhtml, $ini, $fin - $ini + 1);
list($null, $fmt) = explode(' ', Jstring::substr($filter, 1, -1));
$val = date(Jstring::trim($fmt), $item->created_on);
$itemhtml = str_replace($filter, $val, $itemhtml);
}

$itemhtml = str_replace('{product_weight}', $item->product_weight, $itemhtml);
$itemhtml = str_replace('{product_length}', $item->product_length, $itemhtml);
$itemhtml = str_replace('{product_width}', $item->product_width, $itemhtml);
$itemhtml = str_replace('{product_height}', $item->product_height, $itemhtml);

$itemhtml = str_replace('{product_mdate}', date($date_format, $item->modified_on), $itemhtml);
while (($ini = Jstring::strpos($itemhtml, "{product_mdate")) !== false) {
$fin = Jstring::strpos($itemhtml, "}", $ini);
$filter = Jstring::substr($itemhtml, $ini, $fin - $ini + 1);
list($null, $fmt) = explode(' ', Jstring::substr($filter, 1, -1));
$val = date(Jstring::trim($fmt), $item->modified_on);
$itemhtml = str_replace($filter, $val, $itemhtml);
}

$prices = $calculator->getProductPrices($item->id);
//echo var_dump($prices);

$priceFormated = array();
foreach ( $prices as $name => $product_price  ){
    $priceFormated[$name] = $currency->createPriceDiv($name,'',$prices,true);
}

$itemhtml = str_replace('{price_symbol}', $item->currency_symbol, $itemhtml);
$itemhtml = str_replace('{country_code}', $item->currency_code_3, $itemhtml);

//$itemhtml = str_replace('{cost_price}', $priceFormated['costPrice'], $itemhtml);
//$itemhtml = str_replace('{price_before_tax}', $priceFormated['priceBeforeTax'], $itemhtml);
//$itemhtml = str_replace('{sales_price_temp}', $priceFormated['salesPriceTemp'], $itemhtml);

$itemhtml = str_replace('{base_price}', $priceFormated['basePrice'], $itemhtml);
$itemhtml = str_replace('{base_price_variant}', $priceFormated['basePriceVariant'], $itemhtml);
$itemhtml = str_replace('{base_price_with_tax}', $priceFormated['basePriceWithTax'], $itemhtml);
$itemhtml = str_replace('{discounted_price_without_tax}',     $priceFormated['discountedPriceWithoutTax'], $itemhtml);
$itemhtml = str_replace('{sales_price}', $priceFormated['salesPrice'], $itemhtml);
$itemhtml = str_replace('{tax_amount}', $priceFormated['taxAmount'], $itemhtml);
$itemhtml = str_replace('{sales_price_with_discount}',     $priceFormated['salesPriceWithDiscount'], $itemhtml);
$itemhtml = str_replace('{discount_amount}', $priceFormated['discountAmount'], $itemhtml);
$itemhtml = str_replace('{price_without_tax}', $priceFormated['priceWithoutTax'],     $itemhtml);

$itemhtml = str_replace('{product_price}', $item->product_price, $itemhtml);
$itemhtml = str_replace('{product_rating}', $rating, $itemhtml);
$itemhtml = str_replace('{product_rating_raw}', $item->rating, $itemhtml);
$itemhtml = str_replace('{product_s_desc}', $item->product_s_desc, $itemhtml);
$itemhtml = str_replace('{product_stock}', $item->product_in_stock, $itemhtml);
$itemhtml = str_replace('{product_full_image}', $image, $itemhtml);
$itemhtml = str_replace('{product_full_image_url}', $imageurl, $itemhtml);
$itemhtml = str_replace('{product_image}', $image2, $itemhtml);
$itemhtml = str_replace('{product_thumb_image_url}', $thumb_url, $itemhtml);
$itemhtml = str_replace('{product_thumb_image}', $thumb, $itemhtml);
//$itemhtml = str_replace('{categorythumbnailurl}', $category_thumb_url, $itemhtml);
*174 LINE** //$itemhtml = str_replace('{categorythumbnail}', $category_thumb,     $itemhtml);***
$itemhtml = str_replace('{category_url}', $categoryurl, $itemhtml);
$itemhtml = str_replace('{index}', $index, $itemhtml);


//Generate add to car form
$cart_bar = '<div class="addtocart-area">
<form method="post" class="product js-recalculate" action="index.php" >
    <div class="addtocart-bar">
        <!-- <label for="quantity' . $item->id . '" class="quantity_box">' . JText::_('COM_VIRTUEMART_CART_QUANTITY') . ': </label> -->';
        $quatity_box = '<span class="quantity-box">
            <input type="text" class="quantity-input" name="quantity[]" value="';
            if (isset($product['min_order_level']) && (int) $product['min_order_level'] > 0) {
                $quatity_box .= $product['min_order_level'];
            } else {
                $quatity_box .= $default_qty ? $default_qty : '1';
            }
        $quatity_box .='" />
        </span>
        <span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
        </span>';

        $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
        $button_cls = 'addtocart-button';
        $button_name = 'addtocart';
        $stockhandle = VmConfig::get('stockhandle', 'none');
        if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and     ($item->product_in_stock - $item->product_ordered) < 1) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
            $button_name = 'notifycustomer';
        }
        vmdebug('$stockhandle ' . $stockhandle . ' and stock ' .     $item->product_in_stock . ' ordered ' . $item->product_ordered);

        $cart_button = '<span class="addtocart-button">
            <input type="submit" name="' . $button_name . '"  class="' . $button_cls .     '" value="' . $button_lbl . '" title="' . $button_lbl . '" />
        </span>';

        switch($show_qty_box){
            case 'none':
                $cart_bar .= '<!-- '.$quatity_box.' -->'.$cart_button;
            break;
            case 'left':
                $cart_bar .= $quatity_box.$cart_button;
            break;
            case 'right':
                $cart_bar .= $cart_button.$quatity_box;
            break;
            case 'top':
                $cart_bar .= $quatity_box.'<div class="clear"></div>'.$cart_button;
            break;
            case 'bottom':
                $cart_bar .= $cart_button.'<div class="clear"></div>'.$quatity_box;
            break;
        }
        $cart_bar .= '<div class="clear"></div>
    </div>
    <input type="hidden" class="pname" value="' . $item->product_name . '" />
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="view" value="cart" />
    <noscript><input type="hidden" name="task" value="add" /></noscript>
    <input type="hidden" name="virtuemart_product_id[]" value="' . $item->id . '" />
    <input type="hidden" name="virtuemart_manufacturer_id" value="' .     $item->virtuemart_manufacturer_id . '" />
    <input type="hidden" name="virtuemart_category_id[]" value="' . $item->cid . '" />
</form>
<div class="clear"></div>
</div>';

$itemhtml = str_replace('{form_addtocart}', $cart_bar, $itemhtml);

?
4

1 に答える 1

0

配列ではない変数に対して foreach を実行しようとすると、 foreach() に指定された無効な引数が発生する可能性があります。配列であると「想定」されているかもしれませんし、配列だと思っていたかもしれませんが、申し訳ありませんが、そうではありません。

このリンクを確認してください。

http://php.syntaxerrors.info/index.php?title=Invalid_argument_supplied_for_foreach

于 2012-07-23T14:58:57.050 に答える