test
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • urfahayatsite Friend
    #143939

    In Joomla, you can define a virtuemart-menuitem and assign a product-id (for example). This works so far. You can click on the menu item and the product flypage is opened. This way, you are able to publish modules on specific virtuemart products or pages.

    The problem is, that the Itemid of the menu is not selected, when you open the product through another way (e.g. browse page, next / previous product). The Itemid is also not selected, when virtuemart has to redirect.

    The reason for that is, that virtuemart searches the #__menu table for the first occurance of virtuemart and uses the menu id found as Itemid. This is mostly not the Itemid you want to have.

    We have created a small script that corrects this behaviour:

    You will have to edit (and backup!!!) the file “/administrator/components/com_virtuemart/classes/ps_session.php”. Find the function url(…) and replace the line in the first if-clause (should be around line 499) with the following code:

    original code:
    [PHP] $Itemid = “&Itemid=”.$this->getShopItemid(); [/PHP]

    change to :

    [PHP] //Start

    // Strip the parameters from the $text variable and parse to a temporary array
    $tmp_text=str_replace(‘amp;’,”,substr($text,strpos($text,’?’)));
    if(substr($tmp_text,0,1)==’?’) $tmp_text=substr($tmp_text,1);
    parse_str($tmp_text,$ii_arr);

    // Init the temp. Itemid
    $tmp_Itemid=”;

    $db = new ps_DB;

    // Check if there is a menuitem for a product_id (highest priority)
    if ($ii_product_id=intval($ii_arr[‘product_id’])) {
    $db->query( “SELECT id FROM #__menu WHERE link=’index.php?option=com_virtuemart’ AND params like ‘%product_id=$ii_product_id%’ AND published=1”);
    if( $db->next_record() ) $tmp_Itemid = $db->f(“id”);
    }
    // Check if there is a menuitem for a category_id
    $ii_cat_id=intval($ii_arr[‘category_id’]);
    if ( $ii_cat_id && $tmp_Itemid==”) {
    $db->query( “SELECT id FROM #__menu WHERE link=’index.php?option=com_virtuemart’ AND params like ‘%category_id=$ii_cat_id%’ AND published=1”);
    if( $db->next_record() ) $tmp_Itemid = $db->f(“id”);
    }
    // Check if there is a menuitem for a flypage
    $ii_flypage=$ii_arr[‘flypage’];
    if ($ii_flypage && $tmp_Itemid==”) {
    $db->query( “SELECT id FROM #__menu WHERE link=’index.php?option=com_virtuemart’ AND params like ‘%flypage=$ii_flypage%’ AND published=1”);
    if( $db->next_record() ) $tmp_Itemid = $db->f(“id”);
    }
    // Check if there is a menuitem for a page
    $ii_page=$ii_arr[‘page’];
    if ($ii_page && $tmp_Itemid==”) {
    $db->query( “SELECT id FROM #__menu WHERE link=’index.php?option=com_virtuemart’ AND params like ‘%page=$ii_page%’ AND published=1”);
    if( $db->next_record() ) $tmp_Itemid = $db->f(“id”);
    }
    // If we haven’t found an Itemid, use the standard VM-Itemid
    $Itemid = “&Itemid=” . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());

    //end
    [/PHP]

    thanks to http://www.vm-expert.com

    nefar Friend
    #318304

    Very cool – Thanks for sharing.

Viewing 2 posts - 1 through 2 (of 2 total)

This topic contains 2 replies, has 2 voices, and was last updated by  nefar 15 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum