Add target=”_blank” to Mashmenu

If your site uses the Mashmenu plug and you would like one of your menu item links to open in a new window, Mashmenu provides the mashmenu_meta filter to do this. Just do a string replace on the href parameter to add the target=”_blank” parameter to the A tag.

Place this code in your theme’s functions.php file.

function mashmenu_page_content( $content ) {

	/* add target blank*/
	$content = str_replace('http://www.google.com/"', 'http://www.google.com/" target="_blank"', $content);
	return $content;

} add_filter('mashmenu_meta', 'mashmenu_page_content');

Tech support for VSP Managed CentOS at Go Daddy

I found that setting up a VSP server with Go Daddy was not very straight forward.  A lot of configuration was required.  I chose the managed CentOS; however, the tech support is only available through chat, which requires a lot of waiting.  Then once getting a chance to chat with them the help was not quite the “Fanatical Support” as I have seen when working on servers from Rackspace.

As an example of Go Daddy’s less than fanatical support, here is a response from one of my recent chats:

You will need to review. I would recommend going through those videos. They are super helpful with the start up process for vps as These servers are sold with the expectation that you are or have a server administrator capable of the configuration and day to day management of the server.

Upgrading dogecoin-qt 1.6 to dogecoin-qt 1.7.1 on Ubuntu 14.04

If you are already running dogecoin-qt 1.6 on Ubuntu 14.04 follow these steps to remove the old version and then install the new version.

If you haven’t created a backup of your wallet, now would be a good time.  In the menu: File -> Backup Wallet…  Then just save it to Dropbox or a USB.  If you need to restore you wallet, shutdown dogecoin-qt and rename your backup file to wallet.dat and place it in ~/.dogecoin, restart dogecoin-qt and you should be good to go.

Now to remove the old version of dogecoin-qt 1.6

sudo apt-get remove dogecoin-qt

Install 32 or 64 bit. My computer uses 64 bit

cd ~/
wget https://github.com/dogecoin/dogecoin/releases/download/v1.7.1/dogecoin-1.7.1-linux64.zip
unzip dogecoin-1.7.1-linux64.zip
cd dogecoin-1.7.1-linux64/
sudo chmod 755 dogecoin-qt
./dogecoin-qt

Resetting your password for WordPress when you cannot receive email

Use this activation URL to reset your WordPress password. You will need access to your database to get the activation key. This is a workaround I had to use on a development site that wasn’t sending emails.

http://domain.com/wp-login.php?action=rp&key={activation_key}&login={user_name}

Dropbox can’t monitor the filesystem

dropbox-cant-monitor-the-filesystem

Dropbox can’t monitor the filesystem

Please run “echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p” and restart Dropbox to fix the problem.

echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p

Get Child Categories in Magento using getChildCategories()

ini_set('display_errors', '1');
error_reporting(E_ALL);

// include magento goodies
require '../app/Mage.php';

Mage::app();

//$currentCategory = Mage::registry('current_category');

$id = 4; //  represents the current category id for my test

$currentCategory = Mage::getModel('catalog/category')->load($id);

$helper = Mage::helper('catalog/category');

if( is_null( $currentCategory ) ) {
	echo '$currentCategory is null';
} else {

	// LEVEL 1
	echo $currentCategory->getName() . '<br>' . PHP_EOL;

	$level_1_children = $currentCategory->getChildrenCategories();

	foreach ( $level_1_children as $level_2 ) {
		// LEVEL 2
			echo '-' . $level_2->getName() . '<br>' . PHP_EOL;
			$level_2_children = $level_2->getChildrenCategories();
			foreach ( $level_2_children as $level_3 ) {
				// LEVEL 3
				$level_3->load();
				if( $level_3->getIncludeInMenu() ) {
					echo '--' . $level_3->getName() . '<br>' . PHP_EOL;
				} else {
					echo '--<span style="color:magenta">' . $level_3->getName() . '</span><br>' . PHP_EOL;
				}
			}
	}
}

Fatal error: Call to a member function getHelperClassName() on a non-object

The Problem:

I’m writing a Magento script to display categories in a custom navigation and was getting this error:

Fatal error: Call to a member function getHelperClassName() on a non-object in /var/www/vhosts/dev-site/public_html/app/Mage.php on line 546

 

The Solution:

Mage:app();

 

My Code:

<?php

ini_set('display_errors', '1');
error_reporting(E_ALL);

// include the Magento goodness
require '../app/Mage.php';

Mage::app();

$id = 4; //  category id for this test
?>

<?php $helper = Mage::helper('catalog/category') ?>
<?php $categories = $helper->getStoreCategories() ?>
<?php if (count($categories) > 0): ?>
    <ul class="top-level-category">
        <?php foreach($categories as $category): ?>
            <li>
                <a href="<?php echo $helper->getCategoryUrl($category) ?>">
                    <?php echo $category->getName() ?>
                </a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

WordPress Shortcode snippet

function bartag_func( $atts, $content = '' ) {
	extract( shortcode_atts( array(
		'foo' => 'something',
		'bar' => 'something else',
	), $atts ) );

	return "foo = {$foo}";
}
add_shortcode( 'bartag', 'bartag_func' );