dmertl.com

php

Magento – Override a core page block

October 26, 2010 by dmertl 6 Comments

Using Magento 1.4.1.1.

After reading a seemingly simple tutorial at http://www.exploremagento.com/magento/override-a-magento-core-block-class.php I ran into some problems. To override the catalog modules breadcrumbs you use the following XML:

<config>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <breadcrumbs>Fido_Catalog_Block_Breadcrumbs</breadcrumbs>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

This is fine for the catalog module, but how do you replace the standard breadcrumbs in 1.4.1.1 which are in core/Mage/Page/Block/Html/Breadcrumbs.php? It took me quite a bit of trial and error, but the key here is the declaration of the block in page.xml:

<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>

The type is what indicates how to override. Specifically “page” and “html_breadcrumbs”. To properly override the standard breadcrumbs you would use the following XML:

<config>
    <global>
        <blocks>
            <page>
                <rewrite>
                    <html_breadcrumbs>AIBooks_Page_Block_Html_Breadcrumbs</html_breadcrumbs>
                </rewrite>
            </page>
        </blocks>
    </global>
</config>

The rest of the article should apply just fine. In my package I mirrored the core code with app/code/local/AIBooks/Page/Block/Html/Breadcrumbs.php with your XML going into app/code/local/AIBooks/Page/etc/config.xml.

Posted in: Magento, Uncategorized Tagged: breadcrumbs, Magento, override, php

Using Zend to parse raw SMTP email data

March 11, 2009 by dmertl 3 Comments

I needed to create a script today that takes raw SMTP input from stdin. The project is running on Zend and they have a library for email. However, their documentation is geared toward getting that email from a mailserver. As far as I could find there wasn’t an example of how to create an email object out of the raw SMTP data.

Create a Zend_Mail_Message from the raw string.

$email = new Zend_Mail_Message(array('raw' => $email_str));

To grab the subject:

$email->subject;

All I wanted was the body from the text/plain piece of the email. If you’ve got a multi-part message it’s a little tricky. Here’s what I compiled from Zend’s documentation:

if($email->isMultipart()) {
  foreach (new RecursiveIteratorIterator($email) as $part) {
    try {
      if (strtok($part->contentType, ';') == 'text/plain') {
        $body = trim($part);
        break;
      }
    } catch (Zend_Mail_Exception $e) { // ignore }
  }
  if(!$body) {
    //Error
  }
} else {
  $body = trim($email->getContent());
}
Posted in: Zend Tagged: email, parse, php, raw, smtp, Zend, zend_mail_message

Zend and Doctrine on Mac OS X Leopard

September 11, 2008 by admin 9 Comments

I recently spent several hours beating my head against the wall trying to figure out why Doctrine and Zend weren’t playing nice together. I was using the version of Apache and PHP that comes with Mac OS X Leopard. When trying to load up the site in my Zend framework I got the error:

Warning: Zend_Loader::include_once(Doctrine/Adapter/Mysql.php): failed to open stream: No such file or directory

Which made me think I was missing the mysql adapter for Doctrine. Looking in the Doctrine/Adapter folder, at least with the latest version, you’ll notice there is only a Mysqli.php no Mysql.php. This led me to think that I was missing some essential library for Doctrine. However, this was not the case. The issue is that the build of PHP that comes with Mac OS X Leopard does not include pdo_mysql. The extension is listed in the php.ini file and you can uncomment it, but it won’t load. Rather than try and compile PHP with pdo_mysql support I decided to move to MAMP. Which turned out to be a wonderful choice. It’s got pdo_mysql support in its PHP build. It’s also a great way to do local development since you can easily turn it on, or restart. I would highly recommend it for development on your local machine.

Posted in: Doctrine, Zend Tagged: adapter, Doctrine, leopard, mac, mysql, mysqli, os x, pdo_mysql.php, php, Zend

Blogroll

  • Antarctica
  • Non-coding stuff
  • Photos
  • Rainbows

Recent Posts

  • Resizing optimized animated GIFs in Photoshop
  • Saving an animated GIF in Photoshop with “combine” instead of “replace” frames
  • Mimicking Django Admin Change Form Styling in a Custom Form
  • Installing custom Plex plugins on a Drobo 5N
  • Bug in CakePHP Containable Behavior, Related Records not Being Returned When Parent Contains a Single Field

Categories

  • CakePHP
  • Canon
  • Django
  • Doctrine
  • iPhone
  • mac
  • Magento
  • MS Access
  • MSSQL
  • Photography
  • Python
  • SQL
  • Uncategorized
  • Zend

Tags

@@IDENTITY adapter authentication breadcrumbs CakePHP Canon cocoa Doctrine email eos utility errors iPhone leopard lost cd mac Magento MS Access MS SQL mysql mysqli nosuchtable os x override parse pdo_mysql.php php programming raw redirect smtp SQL sqlite SQL Server triggers updater validation xcode Zend zend_mail_message

Copyright © 2023 dmertl.com.

Omega WordPress Theme by ThemeHall