Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 12, 2012, 04:54:01 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Interested in joining the WebsiteBaker team?
For more Information read
here
or on our
new website
.
149621
Posts in
21098
Topics by
7537
Members
Latest Member:
lotte2
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
badknight
)
#SOLVED# global block called depending on language
Pages: [
1
]
Go Down
Author
Topic: #SOLVED# global block called depending on language (Read 1403 times)
Chaploo
Guest
#SOLVED# global block called depending on language
«
on:
December 17, 2008, 10:00:32 PM »
Hi everybody,
I have a three language WB 2.7 site (english, german, russian) and was wondering if it's possible to create a global block for each language and to call it in the template in any way so that the global block of the right language appears.
I have three global block pages:
DE
- slogan.php
EN
- slogan.php
RU
- slogan.php
And in the template I want to call them as usual like this:
<?php include (WB_URL."/pages/slogan.php"); ?>
But I have to put the language selection in it, I tried something like
<?php include (WB_URL."/pages/".LANGUAGE."/slogan.php"); ?> or
<?php include (WB_URL."/pages/".$lang."/slogan.php"); ?>
But unfortunately it didn't work and my php knowledge is far too little ...
Does anybody have an idea or a hint?
Regards
Jochen
«
Last Edit: December 19, 2008, 10:15:07 PM by Chaploo
»
Logged
Chaploo
Guest
Re: global block called depending on language
«
Reply #1 on:
December 19, 2008, 10:14:49 PM »
If anybody is interested: I finally got an answer to this problem in the German forum, thanks to
BerndJM
!
The solution is:
<?php include (WB_URL."/pages/"
.strtolower(LANGUAGE).
"/slogan.php"); ?>
and - of course - to give each page the right language in the page settings menu.
Regards
Jochen
Logged
whitestream6
Offline
Posts: 4
Re: global block called depending on language
«
Reply #2 on:
December 21, 2008, 11:25:54 AM »
Quote from: Chaploo on December 19, 2008, 10:14:49 PM
If anybody is interested: I finally got an answer to this problem in the German forum, thanks to
BerndJM
!
The solution is:
<?php include (WB_URL."/pages/"
.strtolower(LANGUAGE).
"/slogan.php"); ?>
and - of course - to give each page the right language in the page settings menu.
Regards
Jochen
Thanks, that's useful for me too!
Logged
sare
Offline
Posts: 29
Re: #SOLVED# global block called depending on language
«
Reply #3 on:
January 29, 2009, 08:57:01 AM »
Hi there,
I'm testing global blocks for the first time, and ran into problems.
Doesn't work with WB_URL, but that's a server safety setting it seems (no URLs allowed to include). Can't change that, so have to look further. The curl version someone posted doesn't work either, also due to server settings.
Changing WB_URL to WB_PATH does work, sort of. I have this code:
include_once(WB_PATH."/".strtolower(LANGUAGE)."/leftcolumn.php");
With that the global block shows on the page, but it disregards the template setting (blank template) and uses the default template instead.
I'll trace what exactly happens when doing the include, but it might take some time.
I'd appreciate some comments on this, if you've got global blocks to work without WB_URL.
Logged
masarin
Offline
Posts: 51
Re: #SOLVED# global block called depending on language
«
Reply #4 on:
September 22, 2010, 12:49:01 PM »
Thank you for this info.
It also works with curl:
Code:
<?php
$ch
=
curl_init
();
$timeout
=
5
;
// set to zero for no timeout
curl_setopt
(
$ch
,
CURLOPT_URL
,
WB_URL
.
"/pages/"
.
strtolower
(
LANGUAGE
).
"/block.php"
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
$timeout
);
$file_contents
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
// display file
echo
$file_contents
;
?>
Logged
DarkViper
Development Team
Offline
Posts: 1049
Re: #SOLVED# global block called depending on language
«
Reply #5 on:
September 22, 2010, 01:07:55 PM »
a good idea to use CURL for a simple local include
a new method to buy cigarettes:
1. take a big truck and drive to the tobacco store..
2. move the store onto the truck
3. drive the store to you
4. buy your cigarettes
5. drive the store back
5. move the store back from the truck to it's original place..
finished.... a really simple solution for such a complicated job!
Why not use the very difficult solution, which needs a highest knowledge about starships also, like described in that post:
The heavy Solution
Logged
Anleitungen lesen und selber nachdenken ist anstrengend... Da lass ich doch lieber andere für mich denken...
In
1984
: Nineteen Eighty-Four is a unrealistic utopia!!
In
2012
: Nineteen Eighty-Four is a little piece only of our reality!!
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #6 on:
October 12, 2010, 08:34:39 AM »
Hello
I have two language page and I have tried everything that you'we said in upper posts but non of them is working on my page.
I'we tried:
Code:
<?php
include (
WB_URL
.
"/pages/"
.
strtolower
(
LANGUAGE
).
"/novice_side.php"
);
?>
and
Code:
<?php
include_once(
WB_PATH
.
"/"
.
strtolower
(
LANGUAGE
).
"/novice_side.php"
);
?>
When I tried curl my hole server almost died!
Due to all this nothing is shown on my pages.
right now I have:
Code:
<?php
global
$wb
;
$current_page_id
=
$wb
->
page_id
;
$wb
->
page_id
=
80
;
page_content
(
18
);
$wb
->
page_id
=
$current_page_id
;
?>
this works but, not what I need!
any idea?
Logged
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #7 on:
October 18, 2010, 08:05:43 AM »
Anyone??
thx!
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: global block called depending on language
«
Reply #8 on:
October 18, 2010, 08:31:33 AM »
You first include line will probably not work.
It is using WB_URL (
http://www.yourserver.tld
). You should not include that.
The second one might work, as long as the page you are referring to exists.
Try replacing the "include_once" with "
echo
".
It should show the page it tries to include. If you see the pagename
(like
/some/long/path/to/your/webroot
/en/novice_side.php
) the next step is to check if that file exists on your server. (my guess is "no")
Also set your errorlevel (Settings -> Advanced settings) to E_ALL. That might give you some more insight in what is wrong.
Logged
Professional WebsiteBaker Developer
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #9 on:
October 18, 2010, 01:12:34 PM »
Thanx for the reply!
I tried echo and it shows me the right path to my .php file and if I enter these path in the browser it opens the right page. But if I change echo back to include_once nothing is shown. My pages exists in the right folders.
thx
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: #SOLVED# global block called depending on language
«
Reply #10 on:
October 18, 2010, 01:46:48 PM »
if it shows the path you can open in your browser, it is the wrong path (built with WB_URL).
You should see a path (without http://) the webserver can include. That is not a path you can open in a browser.
Logged
Professional WebsiteBaker Developer
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #11 on:
October 18, 2010, 02:00:41 PM »
Sorry didn't say it right
this is the path tha WB shows me:
/var/www/vhosts/festival-kamping-karavaning.si/httpdocs/en/sidebar_novice.php
you can see it here: (testing content) on the right side under the newsletter!
www.festival-kamping-karavaning.si
If I put pages/en/sidebar_novice.php or pages/si/sidebar_novice.php
it shows me that the pages exists. Or am I missing something?
I'm not a ccoder but uderstand a little so be gentle if I'm totally wrong at what Im doing.
thx!
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: #SOLVED# global block called depending on language
«
Reply #12 on:
October 18, 2010, 02:40:40 PM »
In this case you are including a page that is generated by WB.
You should not do that. Including (as a standard PHP function) can be used for php scripts that are NOT part of WB pages.
The page you now want to include is a part of the complete pagebuilding in WB. It is not the page itself.
The second option (some posts ago) where you include the php code is the way to go for including content from other WB pages.
Quote from: Roych on October 12, 2010, 08:34:39 AM
Code:
<?php
global
$wb
;
$current_page_id
=
$wb
->
page_id
;
$wb
->
page_id
=
80
;
page_content
(
18
);
$wb
->
page_id
=
$current_page_id
;
?>
this works but, not what I need!
So the real question is... What do you need?
Logged
Professional WebsiteBaker Developer
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #13 on:
October 18, 2010, 02:57:39 PM »
ok
I would like to have some content that I'we created in WB background, shown on every page, but would like the content to change when I choose some other language.
Code:
<?php
global
$wb
;
$current_page_id
=
$wb
->
page_id
;
$wb
->
page_id
=
80
;
page_content
(
18
);
$wb
->
page_id
=
$current_page_id
;
?>
the code above does the trick but it shows the same content on all languages (in this case page ID 80).
I would like the content to change to its right language so the ID's would somehow have to change on it self when I click a new language.
Don't know if I was clear enough.
«
Last Edit: October 18, 2010, 03:01:12 PM by Roych
»
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: #SOLVED# global block called depending on language
«
Reply #14 on:
October 18, 2010, 03:05:04 PM »
Ok, you should go this way...
Code: (untested)
<?php
global
$wb
;
$current_page_id
=
$wb
->
page_id
;
if (
LANGUAGE
==
'EN'
) {
$wb
->
page_id
=
80
;
//page_id for english pages
} else {
$wb
->
page_id
=
12345
;
//page_id for non-english pages
}
page_content
(
1
);
//use 1 for contentblock 1
$wb
->
page_id
=
$current_page_id
;
?>
Test the language, and use the correct page_id for that language (not 12345)
Note that all pages must have the correct language set..
Logged
Professional WebsiteBaker Developer
Roych
Offline
Posts: 149
Re: #SOLVED# global block called depending on language
«
Reply #15 on:
October 18, 2010, 04:19:08 PM »
Yeeees!! you're the man! It works perfectly!
Thank you very much.
Logged
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...