Skip to main content

Magento Blank Page Issue Fixed

After a recent upgrade from Magento Community Edition 1.9.0.1 to 1.9.1.0, I started noticing blank pages in the admin section (backend only) after certain functions: order entry, email tracking information, order comments. I also noticed no emails were sent out after password reset requests on the front end. I checked /var/log/maillog and didn’t see the messages. However I confirmed SMTP was working.

So, must be code related, I thought. Step 1 in my troubleshooting usually starts in /var/log/httpd/error_log. Upon review I noticed the following:

[Fri Mar 27 12:55:37.491424 2015] [:error] [pid 9974] [client xx.xxx.xxx.xxx:55842] PHP Fatal error: Call to undefined function mb_convert_encoding() in /var/www/html/magento/lib/Pelago/Emogrifier.php on line 556, referer: http://domain/index.php/admin/sales_order_shipment/view/shipment_id/936/key/...

Because I just upgraded, I had a fresh tar ball of my 1.9.0.1 build from the day prior. I ran a diff on the old version and the new version. One of the differences is this file:

$mage/lib/Pelgro/Emogrifier.php

This lib was not in my 1.9.0.1 build. This is new to Magento Community Edition 1.9.1.0.

Apache
This php file was failing to fully execute because of a missing php library (thank you @benmarks). I quick review of phpinfo(); showed I did not load mbstring in php.ini. After installing php-mbstring and restarting Apache, all email functions were confirmed working and the blank page issue went away.

UPDATE: Bootstrap Carousel = WordPress Dynamic Content

This is an update to my original post How to make Bootstrap Carousel display WordPress Dynamic Content, so I’ll keep it short…

The Original Source Code

From Twitter.Github.com/bootstrap
[code]

[/code]
Note: Bootstrap developers have added the .carousel-indicators feature sometime after my original post. Below, you will see my solution for generating the “data-slide-to” values dynamically…

Now with WordPress template PHP for dynamic content

[code]




[/code]
Of course you’re free to pass all sorts of arguments within the query_posts('/*your_arguments*/');. I’ve left out “posts_per_page” this time, allowing the default to be whatever you have for Dashboard Settings > Reading > Blog pages show at most = “?” posts.
Note: I’ve removed .active from the .carousel-indicators li, as well as from the .carousel-inner .item. We’ll add it back with jQuery…

Add “active” Class to first items

[code]
<script>
jQuery(document).ready(function(){
$(“.carousel-indicators li:first”).addClass(“active”);
$(“.carousel-inner .item:first”).addClass(“active”);
});
</script>
[/code]
The script must be called after the bootstrap js file, and preferably this is all happening in the footer.

Insert a Paged Blog Loop anywhere in your WordPress theme

[code]
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query(‘post_type=post&posts_per_page=5′.’&paged=’.$paged); ?>

have_posts()) : $wp_query->the_post();?>


[/code]
Note that the <?php bootstrap_pagination();?> function has already been discussed in our post “Add Twitter Bootstrap Pagination to your WordPress Theme“.

I won’t spend too much time explaining this one. Just know that this will start an independent loop of your choice anywhere you want in your theme templates. And it correctly incorporates wp’s pagination feature, which can be tricky. I primarily use this code in a template I call blog.php. Many clients want either a static home page, or magazine-style home page, but still want a blog-reel displayed elsewhere (a la the common index.php). My blog.php template featuring the above code can be easily added to any internal page of their choice. Of course, there are countless ways to customize the query parameters.

What Happend to WordPress’ Media File URL Option?

Beats me! God only knows why the wp folk decided to hose that option, or maybe it’s a bug. Whatever the case my be, I thought the custom File URL option (found under Settings > Media) was a very handy tool of which I have always made good use, and I want it back real bad. So bad, in fact, I figured out how. Very simply add this to your theme’s functions.php file:
[code]
update_option(‘upload_url_path’, ‘/wordpress/wp-content/uploads’);
[/code]
Obviously, change the path to reflect your needs. Unfortunately, this hard-codes this path from functions.php, so although the field is added back to Settings > Media, and it may look like you can update the path from there, it will not save your changes. But in reality, a developer will only need to change this once or twice.

I find this option handy when developing a site at a temporary domain, knowing it will ultimately be migrated to a live domain. Otherwise, you get a fully-qualified temporary URL embedded in all your media attachments which are going to have to be changed anytime the site is moved to a new domain.
This option has saved me from the headache of having to mess with the wordpress mysql database more than necessary.

I will update this post as soon as I can add some convenience to this temporary solution.

Adding Custom Menu Locations in WordPress Themes

Basic Setup

Step 1: First, we need to register your new menus. In this example, we’ll create the menus Header Navigation and Expanded Footer. Add this PHP code to your functions.php, or link to it in a separate file:
[code]
// Add Your Menu Locations
function register_my_menus() {
register_nav_menus(
array(
‘header_navigation’ => __( ‘Header Navigation’ ),
‘expanded_footer’ => __( ‘Expanded Footer’ )
)
);
}
add_action( ‘init’, ‘register_my_menus’ );
[/code]

Step 2: Let your users know that your menu location exists by adding a message to the front end when no menu is yet assigned. Insert this code directly below the previous:
[code]
function default_header_nav() { // HTML markup for a default message in menu location
echo “


}

function default_expanded_footer() {
echo “


}
[/code]
Step 3: Insert this code into your templates wherever you want your Header Navigation menu to appear:
[code]
<?php
wp_nav_menu(array(
‘theme_location’ => ‘header_navigation’, // menu slug from step 1
‘container’ => false, // ‘div’ container will not be added
‘menu_class’ => ‘nav’, //