Language parameter in custom system plugin

68 views
Skip to first unread message

ljk

unread,
Nov 17, 2014, 7:02:10 PM11/17/14
to joomla-de...@googlegroups.com
Hi,

I have a plugin which is supposed to redirect the user from the standard Joomla registration page to the Virtuemart registration page. The plugin works fine on a regular site, but on a multilingual site, it isn't working. The lang=xx parameter doesn't seem to be added to the redirection URL. This code is for Joomla 2.5 and Joomla 3.x sites.

This is the code that I am using:
[code]
                                $url = 'index.php?option=com_virtuemart&view=user';
                                $menuid = (int) $this->params->get("menuid", 0);  // Get the menu id parameter
                                // Check if this is a multi-lingual site
                                if (JLanguageMultilang::isEnabled()) {
                                    $lang = JFactory::getLanguage();
                                    $languages = JLanguageHelper::getLanguages();
                                    // loop through the lanuguages looking for the one active on the frontend currently
                                    foreach ($languages as $language) {
                                        // Check to see if this is the active frontend language
                                        if ($language->lang_code == $lang->getTag()) {
                                            $url =    $url . '&lang=' . $language->sef .( $itemID ? '&Itemid=' . $itemID : '&Itemid=' . $menuid );
                                            break;
                                        }
                                    }
                                } else {
                                    // code for non-multi-lingual site
                                        $url =    $url . ( $itemID ? '&Itemid=' . $itemID : '&Itemid=' . $menuid );
                                }
                                $app->redirect( JRoute::_( $url, false ), null, null, true, true );
                            }
[/code]

Does anyone know what is wrong with this code?

Thanks for any help on this.

Viper

unread,
Nov 18, 2014, 12:51:05 AM11/18/14
to joomla-de...@googlegroups.com
Why you're checking if site is lulti-language or not? JRoute always attach the language tag if site is multi-language.

ljk

unread,
Nov 18, 2014, 11:54:23 AM11/18/14
to joomla-de...@googlegroups.com
Hi,

Is that for both J2.5 and J3.x that JRoute applies the language code?

On one multi-lingual site that someone using my plugin has, the lang code is not being applied. If Joomla SEF is turned off the plugin works, but as soon as they turn SEF on, the plugin stops working and redirects the user to the home page rather than the VM registration page. Any ideas why?

Thanks.

Viper

unread,
Nov 18, 2014, 12:35:07 PM11/18/14
to joomla-de...@googlegroups.com
At least for J3 - yes. Not sure about J2.5(not tested).

You can debug the plugin. Look at the final url generated by you plugin in multi-lang w/ SEF on/off.
Reply all
Reply to author
Forward
0 new messages