Fix For Phoogle

Posted by justinjohnson on Nov 11th, 2008

This is for the error: Fatal error: Cannot use string offset as an array in /includes/phoogle.php on line 137 , which just started popping up today.

I haven't had time to update the source files yet, but Michael Clark sent along the following fix that seems to work. I'll post an updated php file ASAP

PHP:
  1. it's a minor  patch -
  2. add:
  3. if(!trim($data)) return;
  4. as the new first line of the  characterData function

Phoogle Mentioned on NetTuts.com

Posted by justinjohnson on Oct 16th, 2008

The guys over at Nettuts have written an article called: This is How You Use the Google Maps API and at the bottom of that post the not only give a shout out, but a link to Phoogle

Net Tuts Screenshot
Thanks guys for the shoutout!

Email Templates with CodeIgniter

Posted by justinjohnson on Sep 12th, 2007

The more I use it, the more and more I love CodeIgniter as a framework; in fact I believe I cherish it more than CakePHP due to it's simplicity. One thing that I do like about CakePHP is that by mixing in PHPMailer you get the ability to specify views for your html email and views for your text emails. So you could have multipart emails being sent based off the data in these views.

Sadly, this is one thing that CodeIgniter is lacking. But if you look around the docs long enough (which are absolutely fantastic by the way) you'll see that you can use CodeIgniter's built in template parsing class to do the same thing.

Let's assume that we are building a site that allows users to create an account. When they create an account, they need to get a welcome email from the application. I'm going to assume you know how to build the form and process the data so here's the controller action that handles the mail part of things.

PHP:
  1. function signup(){
  2.  
  3. #stripped out the validation code
  4.  
  5. #stripped out the db insert code
  6.  
  7. $data = array(
  8. 'some_var_for_view'=>'Some Value for View'
  9. );
  10.  
  11. $htmlMessage$this->parser->parse('user/email/signup_html', $data, true);
  12. $txtMessage = $this->parser->parse('user/email/signup_txt'$data, true);
  13.  
  14. #send the message
  15. $this->email->from('test@webdevkungfu.com', 'CSSNinja');
  16. $this->email->to($this->input->post('email_address'));
  17. $this->email->subject('Account Registration Confirmation');
  18. $this->email->message($htmlMessage);
  19. $this->email->alt_message($txtMessage);
  20. $this->email->send();
  21.  
  22. }

Nothing really ground breaking going on here, but notice the two lines that declare the variables $htmlMessage and $txtMessage, these two lines are what's going to allow us to use these views as email templates.

The template parsing class will parse out a template using the following syntax:

PHP:
  1. $this->parser->parse('path/to/view',$data_array);

However, if you pass a true value as an optional third parameter (default is false) CodeIgniter does not render the view, it returns its fully parsed text as a string. So the $htmlMessage variables and $txtMessage variables now hold appropriately formatted code for either a text message or an html message which is exactly what CodeIgniter's email function needs for its message() and alt_message() methods.

Hope this was helpful, post any questions, concerns or moral outrages in the comments.

Phoogle 2.02a Release

Posted by justinjohnson on Jun 16th, 2007

Nothing major here, just fixing the hard coded API Key bug that was causing maps not to display due to the API Key being over it's limit.

Download it at: Phoogle's Homepage

Ruby On Rails: acts_as_emailable

Posted by justinjohnson on Jun 8th, 2007

Matt Beedle has written a solid little plugin called acts_as_emailable that let's site users send each other messages through the site.

A couple of cool things that stood out to me:

1. It doesn't need to send emails it can store the messages on the site (in a db table) but can send emails if it has to using ActionMailer

2. You can make a little message form that sends a message to another user that references user id's instead of actual email addresses

3. It has a couple cool methods like:
user.users_whom_i_have_emailed
user.users_who_have_emailed_me

Full details can be found on Matt's site:

http://matt-beedle.com/2007/06/05/acts_as_emailable/

Phoogle 2.02 w/ Google Geocoding (and International Support)

Posted by justinjohnson on Apr 4th, 2007

One of the biggest complaints I've received in the past few weeks has been lack of international support which I thought I had fixed in 2.01. Also alot of people have asked why I used Yahoo's geocoding API instead of Google's. When Phoogle Maps was first released about a year or so ago Google did not offer a geocoding API. In fact the first version used geocoder.us to get the points, then Yahoo's and now Google's.

The change to Google's Geocoding API should allow greater international support. If it doesn't let me know. Please note that I do read all emails, it's just that due to sheer volume it's hard to respond to all of them.

Thanks to Mike Wilt and several others who have submitted code to this iteration of Phoogle.

Download the file here: http://www.systemsevendesigns.com/phoogle

Using Phoogle with Wordpress (and Dreamhost)

Posted by justinjohnson on Jan 27th, 2007

Dreamhost is a great webhost, in fact if you use the promo code:PHOOGLE at signup you can get 1 year of their level1 hosting for 44.40 (which is less than 4.00 a month). This is normally priced at 119.40!, so you save $75.00!!

Back to the topic at hand. Phoogle by default uses file_get_contents() to access the Yahoo Maps API to get Latitude and Longitude data to pass to your Google Map. Dreamhost disables file_get_contents() for security purposes. However you can get around this by using CURL

Alex Hillman emailed me to tell me that he had written a post to his blog detailing his install of Phoogle on Wordpress and how to change it to use CURL so that it will work on Dreamhost (pretty simple actually)

Check out Alex's blog post about Using Phoogle on Dreamhost

Phoogle Examples

Posted by justinjohnson on Jan 27th, 2007

When I migrated from my old blog/website/webhost one thing that got lost in the shuffle was the examples for the Phoogle Mapping class.

They can be found on the main phoogle page located at http://systemsevendesigns.com/phoogle

Next to the name of each example you will see a link that says source code, which links to a text file containing php code. Obviously you'll need to change the API key to work with your API key and make sure that the path to phoogle.php is correct for your setup, but other than that you should just be able to copy and paste the examples.

CakePHP Zip Code Helper

Posted by justinjohnson on Jan 1st, 2007

If you need to calculate distance in a web app, or maybe say something like "User1 lives approximately 2.1 miles from User2" then you've had to do the math to calculate distances between zip codes. It's a great pain. In the past I've always used this really great class from MicahCarrick called PHP Zip Code Range and Distance Calculation class v1.2.0 ,for an upcoming CakePHP app that I'm building I need to do something like this. So I took Mr. Carrick's class and converted it into a CakePHP Helper. Read on for code samples and instructions... Continue Reading »

Accessing WordPress with CakePHP

Posted by justinjohnson on Dec 27th, 2006

If you're like me, you've fallen in love with CakePHP. It's a tight bit of code that's easy to use and once you have your application using it, easy to maintain and add new features. For my recent redesign of my freelance site www.systemsevendesigns.com I wanted to be able to display my 3 most recent blog posts on the homepage. Both sites run off of different databases, so how do we do it with Cake? (This post assumes you know a little bit about Cake, but is not too terribly complex. Cake newbies welcome!)
Continue Reading »

- Next »

Advertisements

Recent Posts

Categories

Archives

Meta: