[Howto] Multilanguage site with RazorCMS 1.xx [PHP]

Frequently asked questions.

[Howto] Multilanguage site with RazorCMS 1.xx [PHP]

Postby Adminer » Sat Jul 02, 2011 8:07 pm

Hi!

You can find default RazorCMS theme in ./theme folder.
RazorCMS may use 4 theme skins when you are creating your pages in CMS editor.
The others skins you can find on this link: http://razorcms.co.uk/theme-blade-packs.htm

When you have instaled RazorCMS, you can find default category names in your skin definitions.
You have:
a/ top-navigation - for horizontal menu;
b/ sidebar - for your first menu on the left;
c/ footer - for all link for your footer.

You can create your own skin - reading RazorCMS documentation. It's easy, if you have html theme made in css and with <div>:
<div id="top">
<div id="header">Your Header</div>
<div id="menu">Your siedebar</div>
<div id="content">Content on the pages</div>
<div id="footer">Footer links</div>
</div>

Take a look in /theme in default_xhtml.php file: you can find there this structure, but for example, if you have in your html file the text 'Your sidebar', in RazorCMS theme you find in this place
<div id="leftnav">
<?php loadLinks('sidebar'); ?>
<?php BsocketB('public-xhtml-leftnav'); ?>
</div>

Name sidebar is displayed, because it is default category in your CMS.

So, if you create your own category, for example 'secondsidebar' - and "connect" all for example polish, german etc... pages created only to this category - the result will be one:
- now you can see all pages conected to sidebar category, but you can not see polish pages in our example, because your theme is not displayed them by...
<div id="leftnav">
<?php loadLinks('secondsidebar'); ?>
<?php BsocketB('public-xhtml-leftnav'); ?>
</div>
:mrgreen:

You have no such code like this in your default theme in your RazorCMS now.
But you can made it 8-)

You can create your own second theme for this CMS. How?
The rules are easy.

1. You must find /.blade_packs folder in your RazorCMS.
2. You must create new file with "descriptions" there, that you need second theme in RazorCMS ;-)
This file is in xml format, in this example lets do that together and go to create a new page in your php editor (important!!! - don't use notepad or MS Word).

Code: Select all
<?xml version="1.0" ?>
<bladepack>
    <details>
        <name>Second Theme</name>
        <version>v1.0</version>
        <class>theme</class>
        <author>Paul Smith</author>
        <description>Public second RazorCMS default skin theme - ported by Adminer to use with double language on your site</description>
    </details>
    <archive>
        <archive_file>theme_razorpl.zip</archive_file>
        <xml_file>theme_razorpl.xml</xml_file>
        <bladepack_file>theme_razorpl.php</bladepack_file>
        <bladepack_dir>theme_razorpl</bladepack_dir>
    </archive>
    <note>
        <p>This theme blade pack will add the ability to use a different theme on the
        front end of your website. To use this theme on the front end of your website,
        complete the following steps.</p>
        <p>1. Activate this theme in the theme section of the blade manager. 2. Complete
        go to the settings manager and set which theme slot you wish to allocate this theme
        to. You may allocate this theme to any slot.</p>
        <p>Not set it to default, this theme will be used on your entire site. 3. You may select it to use as the second theme - it's will be your choice when you create your new page.</p>
        <p>You may see what slot is allocated to each page when managing content by looking
        for D (theme-default), 1 (theme-one), 2 (theme-two), 3 (theme-three) in the column
        to the left of the page name. 4. IMPORTANT: now you should create polishsidebar category!!! 5. All polish pages
should be connected only to this secondsidebar category !!!! (Not to sidebar!!!)</p>
    </note>
</bladepack>


Save this code with theme_razorpl.xml name.
Ok. Now we have a little xml "description" for our CMS.


Second file should be created "to connect" our new theme. The name of this file should be coresponding with the first file, first was theme_razorpl.xml,
so the second should be: theme_razorpl.php

Create this theme_razorpl.php file with new code:

Code: Select all
<?php
////////////////////////////////////////////////////////
// Blade Pack Theme                                   //
// Second RazorCMS theme by Adminer                   //
// sidebar category was changed by mojelinki category //
////////////////////////////////////////////////////////

///////////////////////
// Socket Allocation //
///////////////////////

// Add Blades to Sockets $bladeList['blade'] = 'socket'; //
$bladeList['razorplXHTML'] = 'public-change-theme';
$bladeList['razorplCSS'] = 'public-css-address';
$bladeList['razorplEditorCSS'] = 'editor-css-path';

///////////////////////
//      Blades       //
///////////////////////

// blade - load new xhtml template //
function razorplXHTML(&$xhtmlTemplate) {
    $xhtmlTemplate = 'blade_packs/theme_razorpl/razorpl_xhtml.php';
}
// end ///////////////////////////////

// blade - load new css template //
function razorplCSS(&$cssTemplate) {
    $cssTemplate = 'blade_packs/theme_razorpl/razorpl_css.css';
}
// end ///////////////////////////////

// blade - load editor css template //
function razorplEditorCSS(&$cssfile) {
    $cssfile = 'blade_packs/theme_razorpl/editor_css.css';
}
// end ///////////////////////////////
?>


Now, you have to create theme_razorpl subfolder in blade_packs folder.
The structure should be like this - you should count '-' to learn about the level structure:

root in public html
- [blade_packs]

-- [theme_razorpl]
--- [images]
--- [scripts]
--- editor_css.css
--- razorpl_css.css
--- razorpl_xhtml.php

-- theme_razorpl.php (now you have it)
-- theme_razorpl.xml (now you have it)

OK. You have to create 'theme_razorpl' subfolder. And You have to create 'images' and 'scripts' subfolders too.
Now you have something to "copy-copy" ;-) from ./theme folder - all files in images folder and scripts folder copy inside new folders.
Copy from ./theme editor_css.css file too.
Find and copy default_css.css file to the new subfolder theme_razorpl, but after coping rename this file to razorpl_css.css

Now you have only to create one file: razorpl_xhtml.php
with a php code:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title><?php loadSettings('sitename'); ?> &raquo; <?php loadPageTitle(); ?></title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php BsocketB('public-xhtml-head1'); ?>
    <link rel="stylesheet" type="text/css" href="<?php cssLocation(); ?>" />
    <link rel="shortcut icon" href="theme/images/favicon.ico" type="image/x-icon"/>
    <?php BsocketB('public-xhtml-head2'); ?>
    <script type="text/javascript" src="<?php scriptPath(); ?>navbar.js"></script>
</head>
<body>
    <div id="brace">
    <div id="pageframe">
    <div id="pageframer">
        <div id="headermid">
        <div id="headerr">
        <div id="header">
            <h1><?php loadSettings('sitename'); ?></h1>
            <h2><?php loadSettings('siteslogan'); ?></h2>
       <?php BsocketB('public-xhtml-header'); ?>
        </div>
        </div>
        </div>
        <div id="midbrace">
            <div id="topnav">
                <?php loadLinks('second-top-navigation'); ?>
                <?php BsocketB('public-xhtml-topnav'); ?>
            </div>
            <div id="midbox">
                <div id="leftbar">
                    <div id="leftnav">
                        <?php loadLinks('secondsidebar'); ?>
                        <?php BsocketB('public-xhtml-leftnav'); ?>
                    </div>
                    <?php loadInfoContents(); ?>
                    <?php BsocketB('public-xhtml-leftbar'); ?>           
                </div>
                <div id="content">
                    <div class="contentwh">
                        <?php loadSlabContents(); ?>
                    </div>
                    <?php BsocketB('public-xhtml-content'); ?>
                </div>
            </div>
            <div id="copyw">
                <div id="copynav">
                    <?php loadLinks('footer'); ?>
                </div>
                <?php loadSettings('copyright'); ?>
                <?php BsocketB('public-xhtml-footer'); ?>
            </div> 
        </div>
        <div id="footer">
        <div id="footerr">
        <div id="footerl">
        <div id="footnav">
            <div id="footerLeft">
                <a href="http://www.razorcms.co.uk">www.razorcms.co.uk</a>
            </div>
            <div id="footerRight">
                <a href="http://www.mis-limited.com">www.mis-limited.com</a>
            </div>
        </div>
        </div>
        </div>
        </div>
    </div>
    </div>
<?php BsocketB('public-xhtml-endofdoc'); ?> 
</body>
</html>



As you can see, there is a code:
<div id="leftbar">
<div id="leftnav">
<?php loadLinks('secondsidebar'); ?>
<?php BsocketB('public-xhtml-leftnav'); ?>
</div>

So, go to the RazorCMS, activate a new theme, go to the Settings - there is a place to choice next theme after Default theme. SAVE !!!

Go to the Content place.
IMPORTANT: Create new category: secondsidebar

OK.
Now go to your Create Contents - Pages and create first polish text for page. You should know, that you must take in Select Theme your new SecondTheme on the top configuration, take your polish text and "connect" it to secondsidebar category only!!!.
Save.
You have created a new page, but this page is not displayed on your home page. But exist now.

Now you may create a new link 'EN-PL' connected to sidebar and to secondsidebar together - but this link should be with a new skin theme you created now - it's very important!

This will be the place to change language, because that link will be displayed only with all links in secondsidebar category - all links from sidebar will not be displayed there.
In the end, you should create new link 'PL-EN', that link should be in secondsidebar displayed, but this link should have oryginal default first RazorCMS theme.
Thats all ;-)

You may use any RazorCMS existings skin theme to do the same, without manual creation in this example, but in second theme you must edit one file and
change line with <?php loadLinks('sidebar'); ?> to the new one: <?php loadLinks('secondsidebar'); ?>.

If you are using top-navigation menu (but not sidebar) with <?php loadLinks('top-navigation'); ?> - do the same with it like in this example with 'sidebar' category - and create 'second-top-navigation' category. and then in your theme use <?php loadLinks('second-top-navigation'); ?>

IMPORTANT: use only small characters to create all names for categories.
Restrictions: you can not create the same names for multilanguage links in your menu.
You do not have the required permissions to view the files attached to this post.
Adminer
 
Posts: 578
Joined: Wed Apr 08, 2009 9:52 pm
Location: Poland

Return to FAQ's

Who is online

Users browsing this forum: No registered users and 1 guest