Bạn ghé thăm diễn đàn lần đầu? hãy đăng ký ngay bây giờ để tham gia.
  • Đăng nhập:

Chào mừng bạn đến với ITVNN FORUM - Diễn đàn công nghệ thông tin.

Nếu đây là lần đầu tiên bạn tham gia diễn đàn, xin mời bạn xem phần Hỏi/Ðáp để biết cách dùng diễn đàn. Để có thể tham gia thảo luận bạn phải đăng ký làm thành viên, click vào đây để đăng ký.


  • Partner Area
    • ITVNN HOSTING - Thiết kế website, Cung cấp Domain, Hosting, VPS Việt Nam Anh Hùng - Thông tin truyền thông
kết quả từ 1 tới 1 trên 1
Tăng kích thước phông chữ Giảm kích thước phông chữ
  1. #1
    LeeHuy's Avatar

    Trạng thái
    Offline
    Tham gia ngày
    Aug 2010
    Thành viên thứ
    29522
    Tuổi
    30
    Giới tính
    Bài gởi
    97
    Level: 33 [?]
    Experience: 484,710
    Next Level: 555,345
    Cảm ơn 37
    Cảm ơn 25 lần / 15 Bài viết

    Default Hướng dẫn fix lỗi pagination khi sử dụng chung sh404sef & virtuemart  

    Lâu quá không có viết bài mới cho SEO Vietnam, thật là rất xin lôi các bạn, số là dạo này công việc của mình khá nhiều nên không có thời gian nhiều để viết thêm bài mới. Hiện tại công việc đã giải quyết song nên mình sẽ tích cực viết bài hơn nữa, mong rằng sẽ vẫn nhận được nhiều sự quan tâm của các bạn như thời gian trước đây.

    Hôm nay không biết nghịch website về trang sức của khách hàng thế nào mà phần sản phẩm sử dụng sh404sef và virtuemart mỗi khi sang trang 2 của trang sản phẩm là không thể nào quay về trang 1 được. Dạo trước cũng có nhiều bạn hỏi mình về các vấn đề như thế này nhưng mà dạo ấy không có quan tấm đến VM nhiều nên cũng không biết phải sử lý ra sao.

    Hiện tại mình đã tìm ra cách giải quyết vấn đề này nên đăng lên cho các bạn cùng tham khảo. Ở đây chúng ta có 2 cách sử lý một là can thiệp và code, 2 là update bản mới nhất và tinh chỉnh trong configuration. Với cấu trúc của sh404sef và Virture Mart thì rất khó để can thiệp vào code của nó nên mình khuyên cáo các bạn nên sử dụng cách update và tinh chỉnh trong configuration của sh404sef.

    Cách thứ 1: Update + Configuration setup:

    - Việc đầu tiên bạn cần làm là update lên phiên bản joomla mới nhất hiện tại là 1.5.14, sh404sef mới nhất, và virtue mart mới nhất hiện tại là 1.1.3.

    - Bước thứ 2, bạn vào sh404sef / Configuration / Plugin :

    trong phần này bạn để ý đến phần Plugin cho Virtue Mart, chọn Yes cho ứng dụng “Using Items per page drop-down list”

    - Bước cuối cùng là save lại và xóa cache của sh404sef đi là song !

    Nếu thức hiện theo cách này thì url của bạn sẽ được chuyển thành:

    Domain.com/parts/Page-1-50.html
    Domain.com/parts/Page-2-50.html
    Domain.com/parts/Page-3-50.html

    đấy là trong trường hợp bạn chỉnh cho hiện thị 50 sản phẩm trên 1 trang, nếu bạn chỉ cho hiển thị 10 hoặc 20 sản phẩm thì số 50 ở url trên sẽ chuyền thành số tương ứng.

    Cách thứ 2: Can thiệp vào code:

    Mở file component/com_sh404sef/sef_ext/com_virtuemart.php

    Thêm đoạn code sau đây vào sau biến

    PHP Code: 
    if (!function_exists('vmSefGetProductName')) 
    PHP Code: 
    // Detect where a menu item with a non-standard Itemid is being processed and simulate a VM internal 'menu' item to facilitate pagination

    global $sess;

    if( !isset(
    $sess) ) {
    require_once( 
    JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'virtuemart_parser.php' );
    }
    $vm_Itemid $sess->getShopItemid();
    // Check whether the Itemid is the usual value for a VM menu item
    if( $Itemid != $vm_Itemid ) {
    // The URL is based on a menu item other than the standard VM menu item (usually the home page)
    // VM always uses the standard VM Itemid value in pagination URLs and so this URL will be updated to
    // use the standard Itemid and to incorporate any menu item parameters, in case pagination is appropriate.
    $menu = & shRouter::shGetMenu();
    $menuItem $menu->getItem$Itemid );
    if( 
    $menuItem ) {
    // Get the menu parameter set
    $menuparams =& new JParameter$menuItem->params );
    // Replicate the logic used by VM to assess whether a browse or product detail page required
    $tmp_product_id $menuparams->get'product_id' );
    $tmp_category_id $menuparams->get'category_id' );
    // Get the page name and remove '.php', if present
    $tmp_page preg_replace('/\.php/'''strtolower($menuparams->get'page' )));
    if( !empty(
    $tmp_product_id) ) {
    $default_page 'shop.product_details';
    } else if( !empty(
    $tmp_category_id) ) {
    $default_page 'shop.browse';
    } else {
    $default_page '';
    }
    $tmp_page = empty($tmp_page) ? $default_page $tmp_page;
    // Check whether the menu item is a browse page or product detail page (other pages are excluded
    $allowed_pages = array(
    'shop.browse',
    'shop.product_details',
    );
    if( 
    in_array($tmp_page$allowed_pages) ) {
    // Clear down the unwanted get vars from the $shGETVars array
    $required_params = array(
    'option',
    'lang',
    );
    global 
    $shGETVars;
    foreach( 
    $shGETVars as $param ) {
    if( !
    in_array($param$required_params) ) {
    unset($
    $param);
    unset(
    $shGETVars[$param]);
    }
    }
    // Reset the Itemid
    $Itemid $vm_Itemid;
    shAddToGETVarsList'Itemid'$Itemid );

    // Replicate the logic used by VM to include specific parameter values
    if( !empty($tmp_product_id) ) {
    $product_id $tmp_product_id;
    shAddToGETVarsList'product_id'$product_id );
    } else if( !empty(
    $tmp_category_id) ) {
    $category_id $tmp_category_id;
    shAddToGETVarsList'category_id'$category_id );
    }
    $tmp_flypage $menuparams->get('flypage');
    if( ( !empty(
    $tmp_product_id) || !empty($tmp_category_id) ) && !empty($tmp_flypage) ) {
    $flypage $tmp_flypage;
    shAddToGETVarsList'flypage'$flypage );
    }
    $page $tmp_page;
    shAddToGETVarsList'page'$page );
    // Process any other menu parameters not already processed
    $params $menuparams->toArray();
    // Exclude system parameters and those already processed
    $excluded_params = array(
    'product_id',
    'category_id',
    'flypage',
    'page',
    'page_title',
    'show_page_title',
    'pageclass_sfx',
    'menu_image',
    'secure',
    );
    // Process each parameter
    foreach( $params as $param => $value ) {
    if( !
    in_array($param$excluded_params) && $value != '' ) { // Note empty() is not used here because zero is valid
    $$param $value;
    shAddToGETVarsList$param$value );
    shRemoveFromGETVarsList$param );
    }
    }
    }
    }
    }

    // Set the page number for browse pages, if not already set
    if( !isset($limitstart) || !isset($limit) ) {
    $my_page explode('.'$page);
    $pagename = isset($my_page[1]) ? $my_page[1] : '';
    if( 
    $pagename == 'browse' ) {
    global 
    $vm_mainframe$mosConfig_list_limit;
    if( !isset(
    $limitstart) ) {
    // VM stores a different default limitstart value for each different browse page. That value must be identified so that the URL
    // is created for the expected page
    // Store the 'current value' of limitstart so that it can be restored later
    $save_limitstart vmRequest::getVar('limitstart');
    // Setting the 'current value' to null allows the stored value (if any) to be retrieved without it being overwritten by a
    // 'current value' that is usually not applicable to that particular browse page
    vmRequest::setVar'limitstart'null );
    // Force a consistent value for category_id when empty
    $category_id = empty($category_id) ? $category_id;
    $limitstart = (int)$vm_mainframe->getUserStateFromRequest"view{$keyword}{$category_id}{$pagename}limitstart"'limitstart');
    shAddToGETVarsList'limitstart'$limitstart );
    // Restore the original 'current value' of limitstart
    vmRequest::setVar'limitstart'$save_limitstart );
    }
    if( !isset(
    $limit) ) {
    // No need to save and restore values here because VM only uses one value globally
    $limit = (int)$vm_mainframe->getUserStateFromRequest"viewlistlimit{$page}"'limit'$mosConfig_list_limit );
    shAddToGETVarsList'limit'$limit );
    }
    }
    }

    // Ensure that $limitstart is a multiple of $limit (this can occur if $limit was changed since $limitstart was set)
    if( isset($limitstart) && $limit ) {
    $limitstart floor($limitstart/$limit)*$limit;
    shAddToGETVarsList'limitstart'$limitstart );

    Bước 2: Vào Configuration của sh404sef làm tương tự như cách 1 đã làm.

    Bước 3: Save lại và delete cache của sh404 đi là ok.

    Hy vọng rằng bài viết này sẽ giúp ích được cho nhiều bạn, có thắc mắc xin để lại comment, mình sẽ cố gắng giải đáp.


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trả lời: 0
    Bài mới gởi: 07-07-2020, 09:49 AM
  2. Đi coi chung kết ở đâu
    By Admiral504 in forum Tán gẫu
    Trả lời: 0
    Bài mới gởi: 26-01-2018, 09:16 AM
  3. Topper Pagination for topics
    By admin in forum v5.x Modifications
    Trả lời: 0
    Bài mới gởi: 18-04-2013, 08:54 AM
  4. Joomla! E-Commerce with VirtueMart
    By MrZen in forum E-books
    Trả lời: 0
    Bài mới gởi: 04-06-2010, 02:30 PM
  5. Cần tìm ông xã chơi game chung
    By steven.phan in forum Góc thư giãn
    Trả lời: 7
    Bài mới gởi: 05-05-2010, 06:46 PM

Tags for this Thread

Bookmarks

Quuyền Hạn Của Bạn

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể chỉnh sửa bài viết
  •