We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Changing box values, etc. | Forum

Cornelius
Cornelius Aug 5 '11
Hello there,

I hope it's not a problem that I have all these questions... So far Oxwall turned out to be the best thing that happened to my community since ning screwed us over... but anyway, here it goes. :)

So is there a way to make it so when they choose a different language, things change in the custom html boxes as well? - Like links, etc. Obviously I need my Hungarian readers to see links to static pages in Hungarian, and English users in English. Also it would be nice if the </title> tag changed, and *possibly* my header image, but that is not essential.

Can this be done at all? If yes, how?

Cheers,

Cornelius
Cornelius
Cornelius Aug 5 '11
In other words, can I use the languageID somehow in my boxes, with javascript or something to change text values?
Cornelius
Cornelius Aug 7 '11
Problem is, I suck at php. But I solved it in a more "primitive way" in Javascript. :)
 
1, First I made it so that I have images in the main menu instead of text, as my theme requires it anyway - in the languages section I put in the image code.

2, I made a JavaScript that changes a given text from one value to another.

3, I made it so that when the first menu item loads (with onload event), the JavaScript function is triggered.

4, I force the image to reload from the server every time (not cache) as it is essential for this code to work - by adding the unix timecode after the image url. This way the name is new every time, and this forces it to reload every time the page loads.

The result is that everytime the Hungarian page loads, the Hungarian menu item image loads, triggering other text on the main page to change by JavaScript.

If you need the codes I can post it here.
Cornelius
Cornelius Aug 9 '11
Okay. :)

So first I went into Languages and edited the "Main" main menu item, with this code:

<img src="...whatever.jpg" alt="Main" border="0" id="mainitem"  onload="Javascript:changeText(1)">
<script type="text/javascript">
document.getElementById('mainitem').src = document.getElementById('mainitem').src + '?unique=' + new Date().valueOf();
</script>

This piece of code will trigger the "changeText" function that I will show you in a sec, also add the date to the name of the picture, forcing it to reload from the server every time. This is really essential, because if the image loads from the cache, the code won't work.

Then I add this code to a box on the main page:

<script language="javascript">function changeText(idElement){
if(idElement==1){
document.getElementById('element'+idElement).innerHTML ='NEW TEXT THAT I WANT TO APPEAR';
}
}
</script>
<ul><li id="element1">TEXT THAT I WANT CHANGIN
</li>
</ul>

You can have as many "elements" as you want.

This is it really, and it works for me. :) Also for the text you can have any html you want, images, etc.

Cheers