Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Spyware, virus, trojan, fake security or privacy alerts? Read the malware cleaning guide. Want to reply to a topic, start a new one, or remove the advertising? Join today (always free).
      
 
Reply to this topicStart new topic
Wordpress blog question
Metallica
post Sep 13 2008, 02:09 PM
Post #1


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



I want to add this to one of the pages in my blog, to display the weather in my area, but I can't figure out where to put it and how.
CODE
<?php $mfgetweather->get_weather('nlxx0015', 'Rotterdam', 'icon,temp,high,low,dayforecast'); ?>


Wordpress version 2.6.2
Plugin MFGetweather 1.6.0 (is activated)
Go to the top of the page
 
+Quote Post
Major Payne
post Sep 13 2008, 03:54 PM
Post #2


Trusted Techie
Group Icon
Posts: 4,478
From: FEMA took "Tin Can" away!
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?

Go to the top of the page
 
+Quote Post
Metallica
post Sep 14 2008, 12:32 PM
Post #3


Spyware Veteran
Group Icon
Posts: 20,739
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.
Go to the top of the page
 
+Quote Post
Major Payne
post Sep 14 2008, 02:06 PM
Post #4


Trusted Techie
Group Icon
Posts: 4,478
From: FEMA took "Tin Can" away!
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.
Go to the top of the page
 
+Quote Post
Metallica
post Sep 14 2008, 10:31 PM
Post #5


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



Hi Ron,

Well maybe if we think out loud, we can figure it out. smile.gif

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.
Go to the top of the page
 
+Quote Post
Ryan
post Sep 15 2008, 10:42 PM
Post #6


GeekU Moderator
Group Icon
Posts: 3,733
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
Go to the top of the page
 
+Quote Post
Metallica
post Sep 16 2008, 04:38 AM
Post #7


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



Thanks Ryan, smile.gif

I'll try that when I get home.
And keep you posted of course.
Go to the top of the page
 
+Quote Post
Metallica
post Sep 16 2008, 11:31 AM
Post #8


Spyware Veteran
Group Icon
Posts: 20,739
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.
Go to the top of the page
 
+Quote Post
Metallica
post Sep 16 2008, 11:56 AM
Post #9


Spyware Veteran
Group Icon
Posts: 20,739
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
Go to the top of the page
 
+Quote Post
Michael
post Sep 16 2008, 06:40 PM
Post #10


Retired Staff
Group Icon
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 blushing.gif too lazy to download the Weather plugin to check the exact code.

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
Go to the top of the page
 
+Quote Post
Metallica
post Sep 16 2008, 10:39 PM
Post #11


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



QUOTE (Michael @ Sep 17 2008, 01:40 AM) *
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.

Go to the top of the page
 
+Quote Post
Michael
post Sep 16 2008, 10:58 PM
Post #12


Retired Staff
Group Icon
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
Go to the top of the page
 
+Quote Post
Metallica
post Sep 17 2008, 02:30 AM
Post #13


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



I'll try those ideas when I get home Michael. Thanks. thumbsup.gif
Go to the top of the page
 
+Quote Post
Metallica
post Sep 17 2008, 12:13 PM
Post #14


Spyware Veteran
Group Icon
Posts: 20,739
From: Netherlands
OS: XP Pro & Vista Ultimate



Your first idea worked Michael. thumbsup.gif

http://www.pieter-arntz.info/wordpressblog/?page_id=33
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   1 / 960 21st March 2008 - 11:16 AM
VirtuallyIdeal started - last by VirtuallyIdeal
No New Posts   0 / 113 5th September 2008 - 08:01 PM
bryon started - last by bryon
No New Posts   5 / 76 1st December 2008 - 08:10 PM
Primevi1 started - last by PedroDaGR8
No New Posts   2 / 41 Yesterday, 03:39 PM
Estam started - last by Estam

RSS Time is now: 3rd December 2008 - 06:50 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.