January 2010

Zend Framework Resources

Zend Framework Resources

I'll try to bring some of the recent lessons learned in Zend Framework here on the blog. The deeper I dig, I realize the framework is very well put together and powerful.

  • The official Zend Framework Manual True to PHP, Zend has a great manual with many examples, though, if you are looking for every explicit directions where to place code you may be disappointed. Since Zend is a very loosely coupled framework, they don't always assume you're using it in the Zend Application setting.

Zend Framework Application Progress

Zend Framework Application Progress

Tonight's programming lessons included

  • Removing Decorators (dt, dd HTML tags) from Zend_Form_Element_Hidden types. There are several Decorators by using removeDecorator
        $addressid = new Zend_Form_Element_Hidden('addressid');
        $addressid->setAttrib('id', 'form-addressid')
                  ->removeDecorator('HtmlTag')
                  ->removeDecorator('Label');
     

Zend Framework Application Progress

Zend Framework Application Progress

Today I learned from Zend Framework.

Redirecting visitors to their intended URI after login

LoginForm.php

  ...
  // Grabs the requested URI from the server and stores it in a hidden field
  $this->addElement('hidden', 'referrer', array('value' => $_SERVER['REQUEST_URI']));
  ...

Then after you complete authentication, send them to the referring URI

  if($form->getValue('referrer'))
      $this->_redirect($form->getValue('referrer'));
  $this->_redirect('index/index');

Credits:
http://stackoverflow.com/questions/1249274/redirect-to-previous-pa

Fighting the machine

Fighting the machine

So today I spent an ungodly amount of time trying to figure out why my Magento module, that worked just fine on my local MAMP installation, didn't work on the Linux staging server.

I thought it was the cache, so I reloaded the cache, changed the cache backend, then I thought it might be a but, then I thought it might be the layouts. The solution? Case. Mac is not case sensitive, Linux is.

Drupal Mimemail missing embedded images [Solved]

Drupal Mimemail missing embedded images [Solved]

A really weird bug in Drupal's Mime Mail module. This module allows you to send HTML emails with links to images and such.

Behavior

Create a newsletter, send a test one, works great.
Send it for real and the embedded images are missing.

I initially thought it was poormanscron, but I don't have that installed on this Drupal site.

More Zend Framework Fun

More Zend Framework Fun

Sending email via Gmail

  $config = array(
      'ssl' => 'tls',
      'port' => 587,
      'auth' => 'login',
      'username' => 'youemail@gmail.com',
      'password' => 'yourpassword'
  );
 
  $gmail = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
  $mail = new Zend_Mail();
  $mail->addTo($this->to);
  $mail->setSubject($this->subject);
  $mail->setFrom($this->from);
  $mail->setBodyText($this->body);
 
  $mail->send($gmail);

As you can see, you need to create an object for Gmail, then create an email object, then tell the email object to use the gmail ob

Getting the Secure (HTTPS) url for Magento

Getting the Secure (HTTPS) url for Magento

Say you want to redirect a customer to a URL. In Magento you'd invoke this little bit of code to produce the URL.

Mage::getUrl('<em>/</em>/post') 

This will produce a url like http://www.example.com/<module>/<controller>/post. The '*' just inserts the current module and controller.

Now you want to redirect to the secure version. Easy. Just simply say so

Mage::getUrl('<em>/</em>/post', array('_secure'=>true)) 

Now that was simple.

Magento and Memcache with some weird bugs

Magento and Memcache with some weird bugs

When I launched some larger sites on Magento in August 2009 I was sold on the slight performance increase that memcache provided the cart. However, I ran into a few bugs and other anomalies that have caused me to abandon the use of memcache with Magento.

Rebuilding the iPhoto library

Rebuilding the iPhoto library

The number of photos I have in iPhoto is around 10,000. I like the new faces feature, but it just kept grinding my CPU for hours and hours and days and days. I stumbled on a way to rebuild the iPhoto library, but it's really hidden and I've never run across this type of a setup from Apple Software.

Essentially you need to hold down Option + Command while starting iPhoto and keep them held down until you get a window asking you what you want to rebuild. Interesting.

Magento broken USPS shipping rates after January 4, 2010

Magento broken USPS shipping rates after January 4, 2010

Our great USPS decided to make some slight name changes to their delivery methods.