Wordpress blog question |
![]() ![]() |
Wordpress blog question |
Sep 13 2008, 02:09 PM
Post
#1
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
CODE <?php $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); ?> Wordpress version 2.6.2 Plugin MFGetweather 1.6.0 (is activated) |
|
|
Sep 13 2008, 03:54 PM
Post
#2
|
|
![]() Trusted Techie Posts: 4,632 From: Now in a MEMA (Katrina) Cottage OS: Win XP/Vista Home Premium. Backup PC: Commodore 64 with 300 baud modem! |
Don't use WordPress, but is the php at least working for you now online and you just need to dress it up a little by controlling the positioning with HTML/CSS?
|
|
|
Sep 14 2008, 12:32 PM
Post
#3
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
Hi Ron,
No the problem is, there are so many php files, I don't know were to put it. |
|
|
Sep 14 2008, 02:06 PM
Post
#4
|
|
![]() Trusted Techie Posts: 4,632 From: Now in a MEMA (Katrina) Cottage OS: Win XP/Vista Home Premium. Backup PC: Commodore 64 with 300 baud modem! |
Guess I'm a little lost then. Not using WordPress makes it hard for me to visualize the problem of placement. Would you want it as a link on all blog pages so people would have a choice to get the weather or to display on all blog pages in its own little box?
Only responded to this thread as I'm always open to learning something and WordPress may be a future project for me. |
|
|
Sep 14 2008, 10:31 PM
Post
#5
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
Hi Ron,
Well maybe if we think out loud, we can figure it out. I want it on this page: http://www.pieter-arntz.info/wordpressblog/?page_id=33 Below the links I want to add something like: Or you can come visit me. Then below or beside each other (have to see what looks best) a Google map of the area where I live and the weather forecast. The editor fo those pages allows you to write all sorts of things, but only accepts html or bbcode. It just prints the php code. |
|
|
Sep 15 2008, 10:42 PM
Post
#6
|
|
![]() GeekU Moderator Posts: 3,747 From: USA OS: Vista Ultimate X64 |
Hey Ron, Metallica. Hope you don't mind me jumping in, but I figured I could be of some use since I know a bit about WordPress.
There are a couple ways to get that code to run on a page. The first is probably the best, since it involves using a plugin, Exec-PHP, to allow PHP to be used in posts, pages, and widgets. The other method would be editing the page.php template to only run the code if the page being displayed is a certain page. The downside to this is that if you ever want to change themes, you would have to make the change in the template again. -Ryan |
|
|
Sep 16 2008, 04:38 AM
Post
#7
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
Thanks Ryan,
I'll try that when I get home. And keep you posted of course. |
|
|
Sep 16 2008, 11:31 AM
Post
#8
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
This didn't work. Added to page.php
CODE if($page_ID==33) { echo 'Or you can come and visit me.'; $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); } Going to try the plugin now. |
|
|
Sep 16 2008, 11:56 AM
Post
#9
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
Geez I feel inadequate;
Using the exec-php generates this error: Fatal error: Call to a member function get_weather() on a non-object in /home/pieter/public_html/wordpressblog/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 7 |
|
|
Sep 16 2008, 06:40 PM
Post
#10
|
|
|
Retired Staff Posts: 1,856 From: Australia OS: Linux |
Problem is that anything you put into eval has to be a fully self contained bit of code. And $mfgetweather which is supposed to be a instance of some class has not been initialized. So you going to need to add something like
$mfgetweather = new WhatEverItIsCalled($some,$args,$here,$maybe); in to you little snippet. Sorry How does the code in post #8 not work? Does it show any error or just do nothing? This post has been edited by Michael: Sep 16 2008, 06:42 PM |
|
|
Sep 16 2008, 10:39 PM
Post
#11
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
How does the code in post #8 not work? Does it show any error or just do nothing? It does nothing at all. It just gets skipped as if the condition is not met. Tried: CODE <?php $mfgetweather = new get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); ?> Result: Fatal error: Class 'get_weather' not found in /home/pieter/public_html/wordpressblog/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 10 Would I need to point out the relative path? I don't think so because MFGetweather is an active plugin, but I thought I'd ask anyway. |
|
|
Sep 16 2008, 10:58 PM
Post
#12
|
|
|
Retired Staff Posts: 1,856 From: Australia OS: Linux |
Ok I downloaded the plugin - can't test it as I don't have word press. But I think this would work.
CODE <?php $mfgetweather = new MFGetweather(); $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); ?> If not try something like this. CODE <?php include('where_ever_you_put_it/mfgetweather.php'); $mfgetweather = new MFGetweather(); $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); ?> The problem here is eval runs in its own little environment so I don't know how much luck you going to have calling a wordpress plugin. Or if you want to go back the the other idea try. CODE if($_GET['page_id']=='33') {
echo 'Or you can come and visit me.'; $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); } This post has been edited by Michael: Sep 16 2008, 11:01 PM |
|
|
Sep 17 2008, 02:30 AM
Post
#13
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
I'll try those ideas when I get home Michael. Thanks.
|
|
|
Sep 17 2008, 12:13 PM
Post
#14
|
|
|
Spyware Veteran Posts: 20,956 From: Netherlands OS: XP Pro & Vista Ultimate |
|
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies / Views | Topic Information | |||||
|---|---|---|---|---|---|---|---|
![]() |
1 / 1,139 | 21st March 2008 - 11:16 AM VirtuallyIdeal started - last by VirtuallyIdeal |
|||||
![]() |
0 / 152 | 5th September 2008 - 08:01 PM bryon started - last by bryon |
|||||
![]() |
9 / 681 | 5th January 2009 - 04:04 AM Ske7ch started - last by Troy |
|||||
![]() |
1 / 37 | Yesterday, 06:05 PM Twisted Mental started - last by Troy |
|||||
|
Time is now: 7th January 2009 - 09:25 PM |
| Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk. |