Welcome to the Cumulus Support forum.

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

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

Embedding a PHP script?

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Embedding a PHP script?

Post by rp4111 »

I was wondering if you could embed a php script into an HTML page? I have a php code from http://saratoga-weather.org/ that shows weather alerts that I'd like to add to the top of my page. If you click that link you can see what im talking about at the top of the page.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

Generally speaking it's the other way around - you can have html in a php page. ie. the page name ends in .php

This so the server knows that it has to process it before it delivers it to the viewers PC.

It is possible to tell the server to check .htm(l) files for php content, but I won't go into that.

Cumulus generates the 'standard' file set with .htm ending. If you wanted one or more of them with .php ending, you would have to disable 'standard' files and name each file individually for upload.
Image
......................Imagine, what you will KNOW tomorrow !
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

I see. So I would need to have my index page as index.php with the .php code for the advisory banner in that? How would it know to display the cumulus files? Sounds like something I could probably do if I had a step-by-step guide to follow.
TNETWeather

Re: Embedding a PHP script?

Post by TNETWeather »

A php file can have only HTML in it. So you could start out by simply changing all your HTML files to end in the extension of .php and they would still work just as if they were .htm or .html files.

PHP is "activated" by a switch like <?php which tells the PHP enabled web server that what follows is PHP code not just HTML. The switch is turned off by ?> which again tells the webserver that the PHP mode is off.

I have an example of a PHP included template that might give you some more insight that I wrote several years so that you could play with.

http://www.tnetweather.com/nb-0200/

There are also tons of PHP code, code snippets, and full scripts out there just for the looking. Just type php in google and away you go.
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

Thanks for that info Kevin. Might have to play around with this tomorrow afternoon. So would it be possible to modify the Saratoga Weather script to work with Cumulus? I use to run Weather Display and had that script up an running for a while. It seems I would just need to get rid of the AJAX dashboard and replace it with the files cumulus generates?
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

Which files would I have to make into .php to get this started?
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

Which files would I have to make into .php to get this started?
What page do you want php script to run in :D

You could rename all htm(l) files .php if you wish, they will still work in the same way.
.. but don't forget to change your link references ;)
Image
......................Imagine, what you will KNOW tomorrow !
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

I'd like it to run on my main page, the index.htm. Do I rename the template files only or all files in the web folder?
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

Here's where things get awkward .....

'Standard' files processed and uploaded by Cumulus automatically MUST have all of the correctly named Templates available, and will create the .htm files whether you like it or not !

If you want Cumulus to 'build' your page then you will have to turn 'off' "Include Standard files", and declare them (Templates and distant 'name') seperately.

eg. PC .... Cumulus/web/indexT.htm to web ... index.php

Unfortunately you can't / shouldn't just add that as well as the 'Include Standard files'.
You would have TWO index files, depending on how the server has been set up will decide which one has 'priority'.

People using php, usually build their page using php (see phpwebtags). ie. The page(s) on the server are 'static', only uploaded once. But you use Cumulus to generate a data file which you upload and use that together with php to 'fill in the blanks'.
Image
......................Imagine, what you will KNOW tomorrow !
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

Thanks for getting into a bit more detail about this. It sounds like it would be some "work", atleast for a novice like myself.

I found a site where you can embed an RSS feed on your page from any source. The box is big and bulky but that's the best I could find for now without using the .php method.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

There are lots of RSS wigets out there, here is a 'flash' configurable one http://www.springwidgets.com/widgets/view/23/
Image
......................Imagine, what you will KNOW tomorrow !
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

Yes, I finally found one that is very customizable. Just a slight problem though, Seems when you click on an advisory it trys to open a non existent page on my site rather than the outside source.

IE: This is the page's URL that should open http://www.weather.gov/alerts-beta/wwaa ... p?x=MAZ011
But when clicked on it comes up http://www.westspringfieldwx.com/alerts ... p?x=MAZ011

Basically it replaces the weather.gov with my site address. I can't seem to find how to change this in the code, possibly im overlooking it.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

Your url ?
"widget" source ?
Image
......................Imagine, what you will KNOW tomorrow !
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: Embedding a PHP script?

Post by rp4111 »

User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Embedding a PHP script?

Post by beteljuice »

It works when I view your site (although the mouseover is a bit odd), you need to change newwindow=0 so that it opens in a new window and people don't 'lose' your site.
Image
......................Imagine, what you will KNOW tomorrow !
Post Reply