Force All Links on a Page to Open In a New Window

A neat little tag that I used recently to force all of the links within an iFrame page to open in a new window without having to update each link manually:

This worked great for updating the links in a Facebook specific iFrame, that way I could pull in dynamic content without having to update the WordPress post links, widgets, etc. to include taget=”_blank”.

I had direct access to the iFrame source, but I also found a script that may allow you to do this from the top level page where you are calling the iFrame as well.


$(document).ready(function()
{
var baseTag= document.createElement('base');
baseTag.target = '_blank';
$("iframe html head").append(baseTag);
});

bbPress 2.0 (plugin) – Adding User Role to Replies

In bbPress 2.0, the recent plugin version, that comes packed with the twentyten bbPress theme, I noticed that a role was not being displayed within the topic reply template.

I ended up adapting the core design from twentyten to WooThemes Canvas and felt the forum role was an essential aspect that was missing.

I came up with a quick solution but perhaps you can contribute a more dynamic solution for removing the bbp_ prefix that is included when simply displaying a bbPress Role.

Here is what I came up with:

roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
if ( $role == bbp_moderator ) {
echo 'Moderator';
} elseif ( $role == bbp_participant ) {
echo 'Participant';
} else {
echo $role;
}
}

?>

Importing Images From External URL into Magento

There are occasions where you might not have access to downloading the images from your current setup into the Magento or it is simply easier to reference the current file path on an external URL. The following snipet will add the ability for you to grab images from an external URL when importing products through a data feed. Rather then setting up the image column within the data feed with /image-name.jpg you can now use the full URL path http://www.domain.com/image-name.jpg as an example.

Download the following file – app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php and search for the following section of code:

foreach ($imageData as $file => $fields) {
try {
$product->addImageToMediaGallery(Mage::getBaseDir(‘media’) . DS . ‘import’ . $html_filename, $fields);
}
catch (Exception $e) {}
}

Comment out the previous section of code or replace tit with the following:

foreach ($imageData as $file => $fields) {
$path_parts = pathinfo($file);
$html_filename = DS . $path_parts[‘basename’];
$fullpath = Mage::getBaseDir(‘media’) . DS . ‘import’ . $html_filename;
try {
$ch = curl_init ($file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec($ch);
curl_close ($ch);
if(file_exists($fullpath)) {
unlink($fullpath);
}
$fp = fopen($fullpath,’x’);
fwrite($fp, $rawdata);
fclose($fp);
}
catch (Exception $e) {}
try {
$product->addImageToMediaGallery(Mage::getBaseDir(‘media’) . DS . ‘import’ . $html_filename, $fields);
}
catch (Exception $e) {}
}

Upload the updated Product.php file to into your local setup to prevent overwriting during upgrades – app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php

Selecting Custom Magento Transactional Emails

For reference, these are the places the transactional e-mails can be adjusted:

General:
Currency Setup – Scheduled Import Settings
* Contacts – Email Options

Catalog:
Catalog – Product Alerts
Google Sitemap – Generation Settings
* Email to a Friend – Email templates

Customers:
* Newsletter – Subscription Options
* Customer Configuration – Create New Account Options
* Wishlist – Share options

Sales:
* Sales Emails – Order
* Sales Emails – Order Comments
* Sales Emails – Invoice
* Sales Emails – Invoice Comments
* Sales Emails – Shipment
* Sales Emails – Shipment Comments
* Sales Emails – Credit Memo
* Sales Emails – Credit Memo Comments
Checkout – Payment Failed Emails

Advanced:
Admin – Admin User Emails
System – Log Cleaning

(* Per storeview/language)

Test Credit Card Numbers

Credit card numbers that can be used to test Magneto’s connection with Authorize.net in test mode.

American Express

Card Number 370000000000002
Expiration 05/2011
Vcode 1111

Useful WordPress Template Updates

A continual collection of WordPress template and code changes that I find useful when designing and developing WordPress blogs.

Body Class Reference

Especially when developing a number of custom elements on specific pages of your site you will want to be able to call that specific page or body class using the following update to the header.php file

Replace

<body>

With

<body <?php body_class( $class ); ?>>

Styling Your WordPress Page List

In customizing WordPress navigation bards I have found it increasingly important to continue to add addition html into such WordPress functions as a simple page list. As as example I sought to add a <span> before and after each link in a standard page list.

I have come across two solid solutions. One being a custom page list:

<ul>
  <?php $list = wp_list_pages('echo=0&title_li=');
  $list = str_replace('<a ','<span><a ',$list);
  $list = str_replace('</a> ','</a></span>',$list);
  echo $list; ?>
</ul>

However the second solution is a simple update to the wordpress page list that is already commonly used throughout wordpress template files:

<ul>
<?php wp_list_pages('title_li=&depth=1&link_before=<span>&link_after=</span>'); ?>
</ul>

You may want to also include the additional sort order function when adding the page list to your blog's setup:

<ul>
<?php wp_list_pages('sort_column=menu_order&title_li=&depth=1&link_before=<span>&link_after=</span>'); ?>
</ul>

Why SEO is NOT Important for Blogs

Blogging is about creating a continual steady stream of information and building your blog as a source of information related to your market.

Other then the traditional SEO functions such as SEF URLs, post titles, relevant content and auto-populated description tags there is little importance in keyword stuffing meta tags or any other ‘traditional’ technique of optimizing a website. Any blog design should already include a number of the beneficial aspects of SEO including H tags as the basis of your individual post page titles as well as any post information that you include.

Because blogs do not primarily focus on building exposure for a single post or page SEO aspects such as keyword density and such simply lose their overall value. If you are creating articles about relevant topics you are most likely naturally including keyword rich content so the focus of your blog becomes more about writing articles on interesting topics and utilizing social media avenues such as social bookmarking sites to increase the exposure of your blog posts and link popularity of your blog on a whole.

Technically you could consider optimizing the main category pages of your blog, but again, optimization on a page by page basis is not the focus of the blog itself as streamlining your blogging process is gravely important as you look to post on a daily basis. SEO overall is most beneficial for static informational or product pages on a site where you are looking to increase that specific pages exposure.

In blogging and building relevant information pertaining to that page’s focus you will most likely look to expand upon the information you offer pertaining to that page whether it be news, product breakdowns, reviews or any other important topics surrounding your focus.

Blog platforms are also a very diverse and powerful platform. WordPress has extensive plugins for everything from creating a review site to building your own social media platform. Especially if you are looking to utilize your blog as a way to build link popularity and increased exposure for your ,posting and social bookmarking become the most streamlined way of accomplishing this. Since link building, in my opinion, is not a traditional aspect of SEO, no single SEO technique outweighs the fundamental reason a blog is created and why any business needs to get involved in social media with their business blog as the hub.

Any website on the other hand should have key components in place in order to target visibility in any major search engines. Contradictory to popular belief, more focus should be placed on categorization and the overall setup of your site not keyword stuffing.

Only once you have established a solid setup will the true benefits of building link popularity be seen through your website’s natural search engine listings.

Customize the Content Layout on Magento Category Pages

Add content above and below Magento product listings using the Category Description available in 1.4, then updating where the static block displays on the category page when customizing the Display Settings to include both a static block and products.

The main focus of being able to customize the content in Magento category pages was to add the ability for me to be able to have an introductory paragraph of content, but also add additional content after the product listing. Thus I was able to add a foundation of custom content to main category pages without pushing the products further and further down the page. [Read more…]

Add Pagination In Product Listings

I have noticed on a number of Magento websites that I have been designing, don’t include the pagination or pager links within the category listings. To remedy this oversight, simply update catalog.xml to include call to pager.phtml file wiht the following code:

<block type=”page/html_pager” name=”product_list_toolbar_pager”/>

You will want to locate the reference to the Product List Toolbar and updated to match the following:

<block type=”catalog/product_list_toolbar” name=”product_list_toolbar” template=”catalog/product/list/toolbar.phtml”>
<block type=”page/html_pager” name=”product_list_toolbar_pager”/>
</block>

Just place the pager reference inside the Product List Toolbar and you are set. Rememeber to refresh your cache before trying to view the live changes.