New Balbooa Forms Released

Continue Reading
Mon. - Fri. 9 am - 5 pm Ask a Question
Remember me

How to multilanguage gridbox system pages TUTORIAL

9 months 1 week ago #1

  • Juan Vilar's Avatar
  • Juan Vilar
  • Posts: 18
Ok, so this is a small hack I have crafted to manage Multilanguage websites for system pages.

This tutorial will help you have a multilanguage site for a SEARCH RESULT PAGE.

the first thing we need to do is to have access to our database, so grab whatever favourite database explorer for mysql you can find. In my case i'm going to be using navicat mysql.

first things first, head over to the table jos_system_gridbox_pages and take a look at the record with id = 3.
Copy this record and paste a new record. you'll notice the ID changes (depending on your database explorer you might need to change the ID manually.

Do this manually for each language that you are using. In my case I am using Spanish + ENGLISH, so you can see i now have two different system pages with two different languages. one for spanish and one for english... pretty easy up to here, right?

Ok, now I want you guys to head over to the joomla system pages editor and you'll be seeing 2 different system pages.

You can edit both differently, one in english and one in Spanish.

Now quickly head to the file manager of your choice and browse around your joomla code tree until you get to components / com_gridbox / views / search / view.html.php

Take a look at the code that you have there and change it to the way you see here

In my case, i have 2 languages so the code snippet is you can see, one for english and one for spanish. The numbers 3 and 5 correspond to the ID of the search pages in the jos_gridbox_system_pages (or whatever the table in your system is with the correct prefixes like alskja_gridxbox_system_pages or whatever ).

the display function that must remain is this one
public function display($tpl = null)
        $language = JFactory::getLanguage()->getTag();
		if ($language == 'es-ES')  $gotoId = 3;
		else $gotoId = 5;
		$this->item = gridboxHelper::getSystemParams($gotoId);
        $this->item->html = gridboxHelper::checkModules($this->item->html, $this->item->items);

so, in your code , you must edit the following lines:
if ($language == 'es-ES')  $gotoId = 3;
		else $gotoId = 5;

so that it matches your language and -> database entries as we previously talked before. The tag es-ES is whatever language tag your system is using. (in my case I use en-GB and es-ES, but you could use many more)

pretty simple, the results are as you see:

depending on the language, the system will display search results on one ID or another.

i hope this is useful for all of you out there.

9 months 1 week ago #2

  • Juan Vilar's Avatar
  • Juan Vilar
  • Posts: 18
To get personalized 404 error pages (more personalized than the language basis + message).

head over to jos_gridbox_system_pages (or however your prefix is) and copy in the same way the 404 code, one for each language, in my case i've done it for spanish and english
take note of those ids.

Then head to the joomla gridbox system section, you'll see a new 404 error page, assign a different language theme in each (if needed, or if you have it sorted this way) and also tell the system to include headers and footers (if you want them there).

Now , head over to / templates / gridbox / error.php

change the file contents for the following
* @package   Gridbox template
* @author    Balbooa
* @copyright Copyright @ Balbooa
* @license GNU/GPL

defined('_JEXEC') or die;

$language = JFactory::getLanguage()->getTag();
if ($language == 'es-ES')  $gotoId = 6;
		else $gotoId = 1;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
$id = 1;
JLoader::register('gridboxHelper', JPATH_ROOT . '/components/com_gridbox/helpers/gridbox.php');
$id = gridboxHelper::getTheme($gotoId, false, 'system');
$data = array('id' => $gotoId, 'theme' => $id, 'edit_type' => 'system');
$page = new stdClass();
$page->option = 'com_gridbox';
$page->view = 'page';
$page->id = $gotoId;
$data['page'] = $page;
$this->params = gridboxHelper::getThemeParams($id);
$params = $this->params->get('params');

$error = gridboxHelper::getSystemParams($gotoId);
$error->html = gridboxHelper::checkModules($error->html, $error->items);
$code = $this->error->getCode();
$message = $this->error->getMessage();
$error->html = str_replace('{gridbox_error_code}', $code, $error->html);
$error->html = str_replace('{gridbox_error_message}', $message, $error->html);
$time = $this->params->get('time', '');
if (!empty($time)) {
    $time = '?'.$time;
$error->options = json_decode($error->page_options);
if ($error->options->enable_header == 1) {
    $footer = $this->params->get('footer');
    $header = $this->params->get('header');
    $layout = $this->params->get('layout');
    $fonts = $this->params->get('fonts');
} else {
    $fonts = '{}';
$fonts = gridboxHelper::prepareFonts($fonts, 'com_gridbox', $gotoId, 'system');
$style = gridboxHelper::checkCustom($id, 'page', $time);
$website = gridboxHelper::getWebsiteCode();
if ($error->options->enable_header == 1) {
    $footer->html = gridboxHelper::checkModules($footer->html, $footer->items);
    $header->html = gridboxHelper::checkModules($header->html, $header->items);
$doc->addScript(JUri::root(true) . '/media/jui/js/jquery.min.js');
$doc->addScript(JUri::root(true) . '/media/jui/js/bootstrap.min.js');
$doc->addScriptDeclaration("var JUri = '".JUri::root()."';");
$doc->addScript($this->baseurl . '/templates/gridbox/js/gridbox.js');
$doc->addScriptDeclaration("var themeData = ".json_encode($data).";");
$doc->addStyleSheet($this->baseurl . '/templates/gridbox/css/gridbox.css');
$doc->addStyleSheet($this->baseurl . '/templates/gridbox/css/storage/responsive.css'.$time);
if (!empty($fonts)) {
$breakpoints = json_encode(gridboxHelper::$breakpoints);
$disable_responsive = gridboxHelper::$website->disable_responsive == 1 ? 'true' : 'false';
$doc->addScriptDeclaration("var breakpoints = ".$breakpoints.";");
$doc->addScriptDeclaration("var menuBreakpoint = ".gridboxHelper::$menuBreakpoint.";");
$doc->addScriptDeclaration("var disableResponsive = ".$disable_responsive.";");
$stylesheets = gridboxHelper::returnSystemStyle($doc);
$dispatcher = JEventDispatcher::getInstance();
<!DOCTYPE html>
<html xmlns="" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>"
    dir="<?php echo $this->direction; ?>">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title><?php echo $this->title; ?> <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></title>
    if (!(bool)gridboxHelper::$website->disable_responsive) {
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    } else {
    <meta name="viewport" content="width=device-width">
    if ($this->direction == 'rtl') {
        <link rel="stylesheet" href="<?php echo $this->baseurl; ?>/media/jui/css/bootstrap-rtl.css" type="text/css" />
    <link href="<?php echo $this->baseurl; ?>/templates/gridbox/favicon.ico" rel="shortcut icon" type="image/" />
    echo $stylesheets;
    echo "\n".$website->header_code;
    echo $style."\n";
<body class="com_gridbox page">
    <div class="ba-overlay"></div>
if ($error->options->enable_header == 1) {
    <header class="header <?php echo $layout; ?>">
        <?php echo $header->html; ?>
    <div class="body">
        <div class="row-fluid main-body">
            <div class="span12">
if (JFactory::getUser()->authorise('core.edit', 'com_gridbox')) {
            <a class="edit-page-btn" target="_blank"
               href="<?php echo JUri::root().'index.php?option=com_gridbox&view=editor&edit_type=system&tmpl=component&id=1'; ?>">
               <i class="zmdi zmdi-settings"></i>
               <p class="edit-page"><?php echo JText::_('EDIT_PAGE'); ?></p>
            echo $error->html;
if ($error->options->enable_header == 1) {
    <footer class="footer">
        <?php echo $footer->html; ?>
if ($params->desktop->background->type == 'video') {
    <div class="ba-video-background global-video-bg"></div>
echo $website->body_code."\n";
$out = ob_get_contents();
$out = gridboxHelper::compressGridbox($out);
echo $out;

now, take a close look at the following code lines at the beginning of the code
$language = JFactory::getLanguage()->getTag();
if ($language == 'es-ES')  $gotoId = 6;
		else $gotoId = 1

as you can see, this is personalized for my IDs in my system pages database, so you'll have to do yours by your own.

so, imagine you have russian, french and german
and each id is 4, 5 and 8

so you'd do
$language = JFactory::getLanguage()->getTag();
if ($language == 'ru-RU')  $gotoId = 4;
if ($language == 'fr-FR')  $gotoId = 5;
		else $gotoId = 8

simple as that :-)

WARNING: If you upgrade gridbox and they have edited any of these files , your changes will be overriden. (this is why we call this a hack)

hope this was useful. to me now it's wonderful cos I can get my visitors that end in a 404 error to read content in their differnt languages, or to add links or more useful information in a perlanguage / country basis

9 months 1 week ago #3

  • Artem's Avatar
  • Artem
  • Posts: 8564
Thank you for sharing! :) Topic added to the top.

Powered by Kunena Forum