Jump to content

Switching language in new custom pages does not work


poliquinp

Recommended Posts

Hello,

 

I tried to look arround before posting but it did not helped me.

 

I have created a new page named « games.php » where I do some sorts for custom queries and custom texts. But when it comes to change the language with the original language switcher, it does not work. I have to go back on the homepage, switch the language and return on games.php to see my changes.

 

In the header, I use those lines of code

 

<ul class="nav-lang">
  <li><a href="{$currentpagelinkback}language=english" data-lang="en"><img src="templates/{$template}/img/svg/english.svg" class="svg" alt="English" width="24" /> En</a></li>
  <li><a href="{$currentpagelinkback}language=french" data-lang="en"><img src="templates/{$template}/img/svg/french.svg" class="svg" alt="French" width="24" /> Fr</a></li>
  <li><a href="{$currentpagelinkback}language=german" data-lang="en"><img src="templates/{$template}/img/svg/german.svg" class="svg" alt="German" width="24" /> De</a></li>
</ul>

 

As I say, it works great on defaults .php pages. Here is my custom games.php code (Almost copied all the code explained on the main documentation -> https://developers.whmcs.com/advanced/creating-pages/ )

<?php

use WHMCS\Database\Capsule;

//define("CLIENTAREA", false);
//define("FORCESSL", false);

require("init.php");

$ca = new WHMCS_ClientArea();

$ca->setPageTitle("Our games");

$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('games.php', 'Our games');

$ca->initPage();

//$ca->requireLogin(); // Uncomment this line to require a login to access this page

# To assign variables to the template system use the following syntax.
# These can then be referenced using {$variablename} in the template.


$games = array();

foreach (Capsule::table('tblproductgroups')->where('id', '>', '3')->where('hidden', '=', '0')->orderBy('order', 'asc')->get() as $group) {

foreach (Capsule::table('tblproducts')->where('gid', '=', $group->id)->get() as $game) {

	$games[$group->id]['games'][] = $game;

}

$games[$group->id]['details'] = $group;


}

$ca->assign('games', $games);

Menu::addContext();
Menu::primarySidebar('announcementList');
Menu::secondarySidebar('announcementList');

# Define the template filename to be used without the .tpl extension

$ca->setTemplate('games');

$ca->output();

Link to comment
Share on other sites

  • 7 years later...

I've created a new page named games.php where I handle some custom queries and texts. However, I've encountered an issue with the language switcher. It doesn't change the language directly on games.php. Instead, I need to go back to the homepage, switch the language there, and then return to games.php to see the changes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated