Page 1 of 3
Web tags in PHP & other PHP items.
Posted: Wed 28 Dec 2011 9:45 am
by duke
I think I've just about got my head around assembling a web page but I would prefer to use PHP tags from the start.
Could some one post a link to a site that uses PHP tags so I (and probably others) can view the source to help me get my head around it?
Thanks,
Duke
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 9:51 am
by nking
I believe Paul uses php
http://www.synewave.co.uk/gcsweather/ (I don't I'm afraid).
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 10:03 am
by beteljuice
Normally speaking you
can't see the source of a php page

Re: Web tags in PHP
Posted: Wed 28 Dec 2011 10:08 am
by steve
Didn't someone produce an equivalent of the 'standard' pages, but using PHP? I can't find a sticky or a download link, or anything in the wiki. If something like that exists, I could try to make it more visible.
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 12:39 pm
by gemini06720
steve wrote:Didn't someone produce an equivalent of the 'standard' pages, but using PHP?
I did...
That was a very very long time ago (in Internet time), more than a year ago...
Unfortunately, the pages are no longer online and cannot be put back online either - too many modifications/updates are required.
As indicated by beteljuice, the source code of a PHP page cannot be seen/viewed. Why? According to the PHP manual, "...the PHP code is executed on the server, generating HTML which is then sent to the client. The client receives the results of running the PHP script, but would not know what the underlying code was. The web server can even be configured to process all the HTML files with PHP, and then there's really no way that users can tell what the operator has up his/her sleeve..."
Duke, it might be time, in the absence of David, to start an online course...

Re: Web tags in PHP
Posted: Wed 28 Dec 2011 3:46 pm
by duke
I've been looking at the courses @ W3S and I will get around to it but I feel I need to do quite a bit of reading first to give myself a better insight to start with.
I see what you mean about the PHP not being visible and now I've thought about it I was asking for the wrong example.
What I should have asked for was a cut and paste from a page using PHP webtags when being edited with notepad++ or similar.
Duke
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 4:05 pm
by gemini06720
duke wrote:What I should have asked for was a cut and paste from a page using PHP webtags when being edited with notepad++ or similar.
Well Duke, that is quite a different request...
Duke, reading about PHP is a good thing, but the best thing is to put into practice the examples usually supplied with most tutorials. What you will need to do to be able to write and test PHP scripts directly on your computer will be to install a local (as on your computer) server. There are quite a few server software available on the Internet but only two that I have using on a regular basis:
XAMPP for Windows (large download size but the package includes everything that is needed - ie: Apache Web Server, MySQL, PHP, Perl) and
Aprelium Abyss Web Server (smaller download size but only the Apache Web Server is included - MySQL, PHP, Perl have to be downloaded separately).
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 4:15 pm
by steve
There's a basic 'using PHP web tags' guide that David wrote, here:
http://wiki.sandaysoft.com/a/Php_webtags
It's just enough to show how they are used; combined with a more general PHP tutorial, it may be of use in producing Cumulus PHP pages.
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 4:16 pm
by scoobs
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 4:39 pm
by duke
I have read that, but for clarification, am I correct in thinking you enter all the code (below) for each webtag, obviously changing the name of the tag?
<?php
require_once("cumuluswebtags.php");
echo $time;
echo "<br/>";
Echo "The current forecast is " . $forecast;
?>
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 4:49 pm
by mcrossley
Not all of it no.
this bit is required once at the top of the file
Code: Select all
<?php
require_once("cumuluswebtags.php");
Then whenever you need to reference a tag you just use the variable name $xxxxx
for instance:
Code: Select all
Echo "The current forecast is " . $forecast;
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 6:23 pm
by duke
this bit is required once at the top of the file
Code:
<?php
require_once("cumuluswebtags.php");
1/ Just once on each page the tags are referenced?
2/ Now I am changing my index.html to use PHP do I now save it as index.php?
Duke
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 10:31 pm
by serowe
One way is to develop the layout of the page you want and then start looking through the webtags to see what is available to provide the informaiton you want.
One site I have set up for a Cumulus user only requires Cumulus generating the cumuluswebtags file and nothing else. The remainder of the display pages are all PHP code which uses the #include functions to pull in the cumuluswebtags file so reference to tags such as $showthetemp, $lowestnighttemp etc etc (not real tags of course for the picky ones out there!) are all translated when the page is displayed. The benefit of doing this is that you don;t have to maintain Cum,ulus template files and then hope that all the relevant pages are transferred to your web site every time you upload (especially helpful if you want 1 minute uploading of the data).
The other benefit of doiong this is that you can use general files for things such as menu's, footers, heading and so on - so instead of having, say, 10 diferent pages and having to code the menu system in all 10, you have a single #include for the menu.php, footer,php, header.php (or whatever you want to call them) in each web page you display.
This is an example of the header.php I sometimes use:
Code: Select all
<?php
require ("cumuluswebtags.php");
?>
<h1><?php $stationlocation ?></h1>
<h2 style="text-align: center; text-transform: none;" >
Latitude <?php echo $latitude; ?> <?php echo $longitude; ?> <?php echo $altitude; ?> <a href="http://maps.google.com/maps/api/staticmap?center=<?php $stationlat ?>,<?php $stationlong ?>&markers=color:red|label:A|-37.870572,145.275324&maptype=hybrid&zoom=10&size=640x640&sensor=false">(Where is this?)</a><br /></h2>
<table width="60%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<?php
include "config/menu.php";
?>
</tr>
</table>
Don't try to pick bones on this as I have changed some of the informaiton just to show how it can work. The first require pulls in the cumuluswebtags file; the latter include pulls in the standard menuing system. So, if this was, say, a basic current weather display, I would have the format of the display page all coded up (less menu's, header, footer) and then, where I need the header, simply use a include "config/header.php"; call and, because this also includes a call to the menu system, I don;t have to worry about it (because wherever I want a header, I also want a menu so the two go hand in hand all the time).
If this makes sense
If you want further help or better code examples/web site example, drop me a PM.
Re: Web tags in PHP
Posted: Wed 28 Dec 2011 11:50 pm
by gemini06720
serowe wrote:If this makes sense

Indeed, Ray, it/that makes perfect sense...
Duke, what I would suggest is that you start with a clean template, meaning with a page with nothing on it and then add the information you would like to display. One procedure Ray demonstrated was the use of multiple templates to create one final page.
For each of my web pages, I use five different templates: a global setting template (which contains values/variables used throughout the site), a top template with the WC3 information, a header template with what appears at the top of each pages and the menus, and the footer template with the copyright notices. Yes, that was just four templates ... the fifth template contains the data (code, tags) that will be appearing on that page.
Duke, I have attached a modified version of the default 'main' template I use to create the pages - just to give you an idea. This is just one of the five templates used.
Re: Web tags in PHP
Posted: Thu 29 Dec 2011 8:27 am
by duke
Thanks very much for the examples, seeing it written can save a lot of reading time. I got quite a bit to be going on with now.
One site I have set up for a Cumulus user only requires Cumulus generating the cumuluswebtags file and nothing else.
I really like the idea of just SFTP one little file. Any chance you could provide a link to that site?
Duke