Page 2 of 3

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 9:25 am
by serowe
My site at http://weather.ser.id.au is one such site BUT the tags file generated contains more than the data available from Cumulus - but the idea is the same - a single webtags generated file containing all of the necessary variables and then each page uses only what it needs to displ;ay the various pages.

Be aware that that link will re-direct you to my server here at home and, if you are trying from a corporate site (i.e. from work) you may *not* be able to get to it as it is located behind a non-standard port - http normally uses port 80 but I re-direct traffic, depending on the port provided, to 10 different web sites on this IP now).

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 4:16 pm
by duke
One small step for man kind.........

I just about had the webtags sorted then you guys threw me another bone by introducing me to a settings / config file.

Do the header, footer and menu code need to be separate files or can they all be produced in one?

I've just deleted the menu from my intended template (http://www.freelayoutsworld.com/free-la ... 974856152/) and put it in a file "sidebar.php" and added the "include" to my test page and it works. I know this is a very small step by your guys standards but seeing it work gives me the encouragement to continue and I understand now why you do it.

Here it is: http://www.nightingaleweather.co.uk/maintemplate.php

Duke

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 8:01 pm
by serowe
It's enturely up to you! (how's that for throwing it back at you? :) )

Seriosly though - you can have as many or a few include files as you want - it all comes down to how YOU want to manage your web site.

For me - I would rather keep the menu's in one file because then, if I need to change the menuing system, I know straight away where to go to make changes to it - I don't have to think 'Now, which file is it in?' Same with a footer (which includes a call to the menu.php file.

If you find you use the ideabar (for example) on one page but not another but stilll want the menu, then obviously you need to seperate them. It's all a case of deciding what is to be used where and how easy the files are to be for editing etc.

Start off with what you are comfortable with then, as yo progress you will find you will make the changes to suit yourself.

Using a config directory is something you will one day work out - for me it's a case of putting the common elements in a standard location. This way if I want to play around with a new display page I know that all the elements for opening my MySQL database(s) are all in one file (dbconfig.php), the menu in another (menu.php), hyeaders another (header.php), footer yet another (footer.php) along with the calls to record user stats. Then there is the css directory for any and all CSS files needed and, finally, data for any TXT style data files. (Again keep in mind that I use all of my weather data from a MySQL database and NOT TXT based files,m thus my need for a dbconfig style file).

Of I haven't confused you even more :)

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 8:19 pm
by duke
That's very helpful, thank you.

I'm just dividing up my template. When I've done what I think is OK I'll post them here for you guys to to tell me where I've gone wrong if that's ok.

Duke

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 9:14 pm
by serowe
You can never 'go wrong' - what pleases some, will (always) displease others (read some of the threads here and you will understand what I mean :) )

The bottom line is 'does it work'? and 'Can I understand what I have done'? If you answer yes to both, then you have achieved what you want and, as time goes on, you will find you will tweak things a bit more, start to play around with the code and eventually (in a hundred years time) say 'I'm finished!'

One thing to also consider trying - install al local web server (WAMPP or XAMPP) on your PC and use it to experiment with. You won't necessarily be able to get the web tags file updated automatically but you can use a local version and see what the page(s) look like before you deploy them on your web site. That way it doesn't matter if everything gets messed up locally - you can fix it and THEN post it to your web site were it appears that you are a master programmer who gets it right first time, every time :)

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 10:59 pm
by duke
install al local web server (WAMPP or XAMPP) on your PC and use it to experiment with
Another bone :D .

Thanks Serowe.

Duke

Re: Web tags in PHP

Posted: Thu 29 Dec 2011 11:15 pm
by serowe
duke wrote:Another bone :D .
It's the marrow in the bones that make them worthwhile though - not just the outside :)

Good luck and, as before, drop me a PM if you need any further help.

Re: Web tags in PHP

Posted: Fri 30 Dec 2011 4:50 pm
by gemini06720
serowe wrote:One thing to also consider trying - install al local web server (WAMPP or XAMPP) on your PC and use it to experiment with. You won't necessarily be able to get the web tags file updated automatically but you can use a local version and see what the page(s) look like before you deploy them on your web site.
Indeed, installing a local server is a requirement to easy/good page design - with a local server one can make some modifications to a template, save the modified file, click on the browser's refresh button, and immediately see the results of the modifications.

As for the wet tag file not being updated - I have no such problem! I just setup Cumulus to read and process the web tag template and to save the resulting PHP script into the drive/directory where all my working web page templates are located - thus it is always up-to-date.

Duke, I am looking at the source code of the template you are working (experimenting) on...
- the '<!DOCTYPE...' should appear only once in a page, at the top of the page (you have 3 of them);
- the '<html...' should also appear only once in a page, at the top of the page, below the '<!DOCTYPE...' (you have 2 of them);
- the '</html>' should also appear only once in a page, at the bottom of the page (you have 2 of them);

Remember, for each opening '<div...' you use, you must have a closing </div> - the total number of opening and closing 'div' must be equal.

Before you get too 'entrenched' into the language, I prefer to direct you in the proper way of writing the code... ;)

You are doing good - keep experimenting, this is how you are going to learn more. And, remember there is a lot of documentation on the Internet, so do not be afraid or reading and trying... :mrgreen:

The pages on my site (link in my signature) are created from PHP templates and JavaScript - all the code on the templates is static and variables (or web tags) are used whereever a value needs to be replace by changing data.

Re: Web tags in PHP

Posted: Fri 30 Dec 2011 6:30 pm
by duke
Duke, I am looking at the source code of the template you are working (experimenting) on...
- the '<!DOCTYPE...' should appear only once in a page, at the top of the page (you have 3 of them);
- the '<html...' should also appear only once in a page, at the top of the page, below the '<!DOCTYPE...' (you have 2 of them);
- the '</html>' should also appear only once in a page, at the bottom of the page (you have 2 of them);
:o Where did they come from? They're not in the file I uploaded (attached).

Page now here (renamed it). http://www.nightingaleweather.co.uk/index2.php

Duke

EDIT:
Just looked at the files on the web server and the extra items are being added to the PHP files when I upload them :bash:

Re: Web tags in PHP

Posted: Fri 30 Dec 2011 7:41 pm
by duke
Duke, I am looking at the source code of the template you are working (experimenting) on...
- the '<!DOCTYPE...' should appear only once in a page, at the top of the page (you have 3 of them);
- the '<html...' should also appear only once in a page, at the top of the page, below the '<!DOCTYPE...' (you have 2 of them);
- the '</html>' should also appear only once in a page, at the bottom of the page (you have 2 of them);
Sorted those out, now I have similar at the start of the forecast script i added (just to give the page some content during experiments).

So, why's that happening?

Duke

Re: Web tags in PHP

Posted: Fri 30 Dec 2011 7:47 pm
by serowe
Without seeing your actual code, my presumption would be you have them in each of the 'included' files (as I can't see them this may be wrong).

Just make sure ANY file you include ONLY includes the snippets of code you want placed in the file - it shouldn't be a complete web page (by complete I mean having a !DOCTYPE, <html></html> set of tags etc etc.

This owuld seem to be the likely culprit but may ot - just something to look out for.

Re: Web tags in PHP

Posted: Sat 31 Dec 2011 12:25 am
by beteljuice
Presumeably there is a setting in the forecast script to include / exclude headers ?

Re: Web tags in PHP

Posted: Sat 31 Dec 2011 3:16 am
by serowe
Ummm he is experimenting with includes so wouldn't/shouldn't be using whole scripts...

Duh!

Re: Web tags in PHP

Posted: Sat 31 Dec 2011 8:59 pm
by duke
Without seeing your actual code, my presumption would be you have them in each of the 'included' files (as I can't see them this may be wrong).

Just make sure ANY file you include ONLY includes the snippets of code you want placed in the file - it shouldn't be a complete web page (by complete I mean having a !DOCTYPE, <html></html> set of tags etc etc.

This owuld seem to be the likely culprit but may ot - just something to look out for.
Correct.
Ummm he is experimenting with includes so wouldn't/shouldn't be using whole scripts...

Duh!
And correct. More importantly, I've corrected my mistake and learned a lesson.

I have a further question. not PHP or tag related but I'll put it here anyway.

When you use the zoom function in the browser I've noticed that rather than enlarge the page background, text and graphics together it only enlarges the text and totally screws up the layout of it. Is this caused by the template I am using?

Here:
http://www.nightingaleweather.co.uk/index2.php
and
http://www.nightingaleweather.co.uk/7dayforecast.php

Duke

Re: Web tags in PHP

Posted: Sat 31 Dec 2011 10:34 pm
by serowe
Now you're in an area I don;t know enough about :) But....what browser are yo using? I use IE9 and if I zoom either of those two pages, they zoom/enlarge exatly as I would expect them to - so not sure if you are seeing something different to me or not.

The only comment I would make about the second link - I presume you are grabbing the forecast from 'somewher' (official Met Office??). You might want to check out their usage T&C's as I don't see any reference or credit to the originators. This implies you are making the forecast and it is possible, in todays litigious society (and definately not saying I agree with it) leaving yourself open to all sorts of potential law suits (not the least being from the actual site the forecasts come from). Just a point to ponder.

Oh - and for those yet to experience it - Happy New Year - just hope wherever you are you don't have the same problem theyt had here in Melbourne where a mid-night foreworks display went wrong when one of the fireworks didn't release properly and set the spire it was being fired from on fire!

http://news.ninemsn.com.au/national/839 ... tches-fire