2014-01-21 14 views
-2

我有一頁完整的產品,當點擊添加到購物車按鈕後頁面重新加載時,我想在添加的產品旁邊顯示覆選標記。 使用的行和列數我已經分配它自己的類,例如如何在特定div中回顯輸出

<div class = "location12"> 

我通過郵寄傳遞的位置,每一個產品的時候添加到購物車按鈕被按下,所以我可以告訴這些div的,按下按鈕是從然後我可以使用這些數據作爲標識符。 我可以通過引用div來讓頁面回滾到這個位置,但我很努力地讓圖像只顯示在那一個產品上。它將顯示在該產品上,然後顯示在該產品之後的每個產品,因爲它在每次第一次輸出後循環時都會回顯。

已加入到個別商品頁,但他們希望這裏相同的功能:http://confettibox.ch/1-NEWSTORE/index.php?main_page=product_info&cPath=576_578&products_id=1265&language=en

這個頁面在這裏: http://confettibox.ch/1-NEWSTORE/index.php?main_page=index&cPath=4_586

添加到購物車按鈕提交在此編碼,並且可以看到其中,我加入了隱藏字段傳遞DIV

$lc_button= '<div class="back">' . zen_draw_form_prod_list('cart_quantity', preg_replace($pattern, $replacement, $string), 'post', 'enctype="multipart/form-data"') . '</div><div class="back qty_bg"><input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_draw_hidden_field('div_id', $colcount.$rows) . '</div><div class="forward">' . zen_image_submit('button_add.jpg', BUTTON_IN_CART_ALT) . '</form></div><br class="clearBoth">'; 

的ID我增加了$ _ POST結果會話VAR這裏:

$_SESSION['location'] = (int)$_POST['div_id']; 

,然後用於:

if ($messageStack->size('listing') > 0 && $_SESSION['location'] == $colcount.$rows) { 

使得messageStack輸出(成功複選標記)將只顯示一個產品...除了它顯示的一切後,太:|

產品都使用該代碼的輸出:

if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') { 
    $lc_text = implode('<br />', $product_contents); 

    $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back featured'. $column .'"' . ' ' . 'style="width:235px;"', 
              'text' => $lc_text = ' 
        <div class="prod_table"> 
        <div class="prod_image"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a></div> 
        <div class="prod_name"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></div> 
        <div class="prod_price back">'. zen_get_products_display_price($listing->fields['products_id']) .'</div> 
        <div class = "location'. $colcount.$rows .'">'.$success.' </div> 
        <div class="prod_content forward">'. $the_button .'</div> 
        </div> 
        '); 
     $column ++; 
    $colcount=$column; 

    if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) { 
    $column = 0; 
    $rows ++; 

    } 
} 
// End of Code fragment for Column Layout (Grid Layout) option in add on module 
$listing->MoveNext(); 

$成功就是我想要的檢查輸出。

我該如何回覆只有'location12'的成功消息? 它甚至有可能嗎?

+0

沒有足夠的信息在這裏幫助。雖然你可能需要Javascript。 – MrUpsidown

+0

你需要顯示你的PHP,一個測試網站的鏈接也不會傷害。 – Wez

+0

@MrUpsidown如果你告訴我你需要什麼信息,我可以給你。小點粘貼整個php文件是無關緊要的 –

回答

1

您還未發佈太多代碼,但我會嘗試回答。 你可以用Javascript或PHP來完成。 使用JavaScript/jQuery的你可以設置你想要的任何div的背景圖片:

$('.location12').css("background-image", "url(/myimage.jpg)"); 

使用PHP,你需要計算你的迭代和只能隨聲附和在$索引== 12的圖像。 我不知道你是否正在使用foreach,for,while或任何其他方法。 假設它是一個foreach循環,你可以做到以下幾點:

$index = 1; 
foreach ($products as $product) { 
if ($index == 12) {echo "<img src=''/>"} 
$index++; 
} 

正如你所看到的,jQuery的方法更容易。

希望這會有所幫助!