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

How to multilanguage gridbox system pages TUTORIAL

4 years 1 month ago #1

  • Juan Vilar's Avatar
  • Juan Vilar
  • Posts: 36
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);
        $this->prepareDocument();
        parent::display($tpl);
    }


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.

4 years 1 month ago #2

  • Juan Vilar's Avatar
  • Juan Vilar
  • Posts: 36
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
<?php
/**
* @package   Gridbox template
* @author    Balbooa http://www.balbooa.com/
* @copyright Copyright @ Balbooa
* @license   http://www.gnu.org/licenses/gpl.html 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');
gridboxHelper::checkSystemTheme($gotoId);
gridboxHelper::setBreakpoints();
gridboxHelper::checkResponsive();
gridboxHelper::checkGridboxLanguage();
$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');
gridboxHelper::prepareParentFonts($params);
gridboxHelper::checkSystemCss($gotoId);



$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);
    gridboxHelper::checkMoreScripts($footer->html);
    gridboxHelper::checkMoreScripts($header->html);
}
$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);
$doc->addStyleSheet(JUri::root().'templates/gridbox/css/storage/style-'.$id.'.css'.$time);
$doc->addStyleSheet(JUri::root().'templates/gridbox/css/storage/error.css'.$time);
if (!empty($fonts)) {
    $doc->addStyleSheet($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();
gridboxHelper::createFavicon();
ob_start();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>"
    dir="<?php echo $this->direction; ?>">
<head>
    <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>
<?php
    if (!(bool)gridboxHelper::$website->disable_responsive) {
?>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php
    } else {
?>
    <meta name="viewport" content="width=device-width">
<?php
    }
    if ($this->direction == 'rtl') {
?>
        <link rel="stylesheet" href="<?php echo $this->baseurl; ?>/media/jui/css/bootstrap-rtl.css" type="text/css" />
<?php
    }
?>
    <link href="<?php echo $this->baseurl; ?>/templates/gridbox/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<?php
    echo $stylesheets;
    echo "\n".$website->header_code;
    echo $style."\n";
?>
</head>
<body class="com_gridbox page">
    <div class="ba-overlay"></div>
<?php
if ($error->options->enable_header == 1) {
?>
    <header class="header <?php echo $layout; ?>">
        <?php echo $header->html; ?>
    </header>
<?php
}
?>
    <div class="body">
        <div class="row-fluid main-body">
            <div class="span12">
<?php
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>
            </a>
<?php
}
            echo $error->html;
?>
            </div>
        </div>
    </div>
<?php
if ($error->options->enable_header == 1) {
?>
    <footer class="footer">
        <?php echo $footer->html; ?>
    </footer>
<?php
}
if ($params->desktop->background->type == 'video') {
?>
    <div class="ba-video-background global-video-bg"></div>
<?php
}
?>
<?php
echo $website->body_code."\n";
?>
</body>
</html>
<?php
$out = ob_get_contents();
ob_end_clean();
$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

4 years 1 month ago #3

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

Regards,
Artem, Balbooa.com

2 years 7 months ago #4

  • LiveWEBS's Avatar
  • LiveWEBS
  • Posts: 9
Great tutorial. I have done it!

2 years 7 months ago #5

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 27059
Let us know if you need more assistance!

Best Regards,
Vyacheslav, Balbooa Support Team

2 years 7 months ago #6

  • tads's Avatar
  • tads
  • Posts: 24
hi, and if i dont have this file?
Attachments:

2 years 7 months ago #7

  • Artem's Avatar
  • Artem
  • Posts: 11020
tads wrote:
hi, and if i dont have this file?

Hi,

Do you have the latest version of the Gridbox? In the admin panel system page "Search" is available?

Regards,
Artem, Balbooa.com

2 years 7 months ago #8

  • tads's Avatar
  • tads
  • Posts: 24
the installed version is 2.10.2
Yes, it appears to search and I have been able to duplicate it in the database, but when I went to modify the file I realized that it does not exist

2 years 7 months ago #9

  • Artem's Avatar
  • Artem
  • Posts: 11020
Send us FTP access to check what's going there. Please use our contact form:
support.balbooa.com/contact-us

Regards,
Artem, Balbooa.com

2 years 7 months ago #10

  • Artem's Avatar
  • Artem
  • Posts: 11020
This file: components / com_gridbox / views / search / view.html.php
is not available in the Gridbox anymore

All changes should be done here:
components / com_gridbox / models / system.php

All Gridbox system pages you will find in this view

Regards,
Artem, Balbooa.com

2 years 7 months ago #11

  • tads's Avatar
  • tads
  • Posts: 24
Hi,i have some doubts actually i tried to install again and in some installation i have this file, but in other installation with the same version and it dont appears, i dont understand why.

Yesterday i try to write with some issue but i donde recieve any answers, i cant see if the tickets i send it really, can i show my tickets in some place in the web? maybe dont arrive the message.

im with the same problems, and need help :)

2 years 7 months ago #12

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 27059
Hello,

Thank you for contacting us!

You need to duplicate the system page as described in the post above.
You need to find the id of your system page that you duplicated (in the admin panel)
Further in file system.php (components/com_gridbox/models/system.php) after line 26 add the code
        $language = JFactory::getLanguage()->getTag();
        // $ id = ID of the original system page
        if ($id == 3 && $language == 'ru-RU') {
            $id = 10; // ID of the page copy for the 1st language
        } else if ($id == 3 && $language == 'fr-FR') {
            $id = 11; //ID of the page copy for the 2st language
        } else if ($id == 7 && $language == 'ru-RU') {
            $id = 12; // id of a copy of another page for the 1st language
        } else if ($id == 7 && $language == 'fr-FR') {
            $id = 13; // id of a copy of another page for the 2st language
        }


Best Regards,
Vyacheslav, Balbooa Support Team

2 years 5 months ago #13

  • Nanozombi's Avatar
  • Nanozombi
  • Posts: 127
Hi Vyacheslav,
Is the file system.php and the location of line 26 still the same? My file looks very different...
And it would be great if we could have an easier way to have multilanguage system pages for the Thank you and Checkout Pages. I don't know if you have developed a simpler way in the meantime.

Thank you,
Xavi

2 years 5 months ago #14

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 27059
Hello,
Thank you for contacting us

You need to add code after line 26, where the code is located
$id = $input->get('id', 0, 'int');

Best Regards,
Vyacheslav, Balbooa Support Team

2 years 4 months ago #15

  • BiLe's Avatar
  • BiLe
  • Posts: 323
Any plans to implement something with backend, so we can quickly copy and edit those pages with language support?

2 years 3 months ago #16

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 27059
Hello,
Thank you for contacting us

This has already been added to the wishlist.
But we will not be able to add this option in the near future,
as we adhere to our plan for adding options (updates, preparation for Joomla 4).

Best Regards,
Vyacheslav, Balbooa Support Team
Powered by Kunena Forum