SimplePortal

Customization => Custom Coding => Topic started by: solarsailor on March 19, 2017, 08:45:41 AM

Title: Page in PHP page
Post by: solarsailor on March 19, 2017, 08:45:41 AM
Hello, people!
I have some little question.
Sorry for my english and 'amazing' php knowledge  ;)

I need to put one page to another, like [SiNaN] made it for blocks (http://simpleportal.net/index.php?topic=5332.msg32204;topicseen#msg32204).

My site has 2 languages. I want to make About-page, but with changeable content inside. If user switch language to english - About-page will be in english too.

So, as i understand, i need to make two BBC pages: aboutEN (with english text) and aboutRU (with russian text). Then i need a php page with code like this:

Code: [Select]
global $context;

if ($context['user']['language'] == 'russian-utf8')
// output russian page

if ($context['user']['language'] == 'english')
// output english page

What code should i put after IF condition to display the page i need?
Title: Re: Page in PHP page
Post by: emanuele on March 20, 2017, 12:10:42 PM
It may be easier to do just one PHP page and:
Code: [Select]
global $context;
$about_page = array(
    'english' => 'This is the content of the about page in English',
    'russian-utf8' => 'This is the content of the about page in Russian'
);

if (isset($about_page[$context['user']['language']]))
{
    $about_language = $context['user']['language'];
}
else
{
    $about_language = 'english';
}

echo parse_bbc($about_page[$about_language]);
Title: Re: Page in PHP page
Post by: solarsailor on March 28, 2017, 07:41:24 AM
Thank you so much!
SimplePortal 2.3.8 © 2008-2024, SimplePortal