Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.0.1 (build 4023) - 16 May 2024

(Note that 4.1.0 (build 4024) - 05 June 2024 remains available, but usage of this version is not recommended - particularly for Davis stations - and the included utility in this distribution for migrating to v4 is known to contain errors affecting conversion of dayfile.txt)

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Reworking a $SITE variable

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
gluepack
Posts: 460
Joined: Tue 22 Jan 2013 9:20 pm
Weather Station: PCE-FWS 20
Operating System: Win 7 Pro
Location: Zlatina, Bulgaria

Reworking a $SITE variable

Post by gluepack »

It is sometimes hard enough to understand how HTML, CSS, PHP, etc. work independently let alone when they are used in conjunction with each other, lol. I came across a piece of code the other day that appeared, to me at least, to have a large portion commented out but the (what I thought was) commented code worked and I am still not sure how.

Anyway, can someone help with this?

Say I have something like this in the templates...

<?php echo somesortoffunction($SITE['alongpieceoftext']); ?>

...sitting between anchor tags which, in turn, are between header tags
and I want to display the content of the alongpieceoftext variable in two different (size) fonts, the first part/#characters/#words in the inherited font and the rest of it in a smaller font. How would I do that? With HTML, CSS or PHP, or a combination? Can I, without screwing up somesortoffunction?

How about if I dispense with the function and just have
<?php echo $SITE['alongpieceoftext']; ?>
I assume that would be a lot easier?
Image

PWS links: WundergroundIVARNAPR3CWOP/APRSE(W)2048PWSWeatherZLATINABGAwekas10631Twitter@Zlatina_weather
Station type: PCE-FWS 20…Webcam link: View south to edge of Provadisko plateau
User avatar
saratogaWX
Posts: 1211
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Reworking a $SITE variable

Post by saratogaWX »

The $SITE[] array is used throughout the template to provide common configuration (and some static text like site name, location, etc) easily configured in the Settings.php with some station-specific variables in the Settings-weather.php.

Some functions in common.php load additional entries in $SITE[] variables from the language-LL.js variables to make available the set of wind directions, heat color words, Beaufort text, month and day names, etc. and are used by various pages and plugins to have the text appear in the currently selected language.

Also in common.php is a function that loads up the current translations into $LANGLOOKUP[] array so the primary langtrans() and langtransstr() functions can translate words/phrases from English to the currently selected language (based on entries within the current language-LL.txt file).

Pages use a construct of

Code: Select all

<?php langtrans('some words here'); ?>
to lookup the 'some words here' and substitute (with exact match) the corresponding words/phrase in the selected language.

Generally, you're free to add new $SITE[] entries as you like -- just don't redefine existing entries to have a different purpose (otherwise strange things may happen to your site).

It is recommended that you do use langtrans() or langtransstr() to process any fixed English text to be displayed on your page so that you can have a translation capability for other languages (when you add the entries to the language-LL.txt file).
I'd recommend you not include additional HTML markup inside a $SITE[] or langtrans()/langtransstr() function call, but instead put the HTML formatting in the page itself and only use the English text in the entry.

I hope this helps.. see http://saratoga-weather.org/wxtemplates ... nguage.php for more info on how the multilingual aspect works.

Best regards,
Ken
User avatar
gluepack
Posts: 460
Joined: Tue 22 Jan 2013 9:20 pm
Weather Station: PCE-FWS 20
Operating System: Win 7 Pro
Location: Zlatina, Bulgaria

Re: Reworking a $SITE variable

Post by gluepack »

Well you were right about it being with regard to use of langtrans. However, as I have incorporated Google Translate into the site, I can probably get rid of it altogether, although for the time being I'll just remove it from the header.php h1.

What I have done is..

Code: Select all

<?php $organis = $SITE['organ'];
$parts = explode("-",$organis);
$part1 = $parts[0];
$part2 = $parts[1];
$part3 = $parts[2];
?>
	<a href="http://www.jerbils.info" title="Go to main site">
                 <?php echo $part1 . "- <font style=\"font-size:75%\">" . $part2 . " - " . $part3 . "</font>" ?></a>
   


which does exactly what I wanted, basically change the size of the second part (well, second and third as I have two "-" in the text) to a smaller font.

It would have been nice to have known how to retain the langtrans function in the statement but, as I said, as I use Google Translate it doesn't really matter.
Image

PWS links: WundergroundIVARNAPR3CWOP/APRSE(W)2048PWSWeatherZLATINABGAwekas10631Twitter@Zlatina_weather
Station type: PCE-FWS 20…Webcam link: View south to edge of Provadisko plateau
User avatar
saratogaWX
Posts: 1211
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Reworking a $SITE variable

Post by saratogaWX »

Ah, you could use

Code: Select all

<?php
$parts = explode("-",$SITE['organ']);
foreach ($parts as $i => $val) { $parts[$i] = langtransstr($val); }
?>
   <a href="http://www.jerbils.info" title="Go to main site">
                 <?php echo $parts[0] . "- <span style=\"font-size:75%\">" . $parts[1] . " - " . $parts[2] . "</span>" ?></a>
And the langtransstr() function would be invoked for each of the sub-parts. :D

Best regards,
Ken
User avatar
gluepack
Posts: 460
Joined: Tue 22 Jan 2013 9:20 pm
Weather Station: PCE-FWS 20
Operating System: Win 7 Pro
Location: Zlatina, Bulgaria

Re: Reworking a $SITE variable

Post by gluepack »

Oh, yes, thanks for that.
Image

PWS links: WundergroundIVARNAPR3CWOP/APRSE(W)2048PWSWeatherZLATINABGAwekas10631Twitter@Zlatina_weather
Station type: PCE-FWS 20…Webcam link: View south to edge of Provadisko plateau
Post Reply