Thursday, February 7, 2013

Filtering categories in the permalink structure

The way to remove the parent category from a permalink when using the 
/%category%/%postname%/ custom structure 
 add_filter( 'post_link', 'remove_parent_cats_from_link', 10, 3 ); 
 
function remove_parent_cats_from_link( $permalink, $post, $leavename )
{
    $cats = get_the_category( $post->ID );
    if ( $cats ) {
     // Make sure we use the same start cat as the permalink generator
     usort( $cats, '_usort_terms_by_ID' ); // order by ID
     $category = $cats[0]->slug;
     if ( $parent = $cats[0]->parent ) {
     // If there are parent categories, collect them and replace them in the link
       $parentcats = get_category_parents( $parent, false, '/', true );
       // str_replace() is not the best solution if you can have duplicates:
       // myexamplesite.com/luxemburg/luxemburg/ will be stripped down to myexamplesite.com/
       // But if you don't expect that, it should work
        $permalink = str_replace( $parentcats, '', $permalink );
        }
    }
    return $permalink;
}

Friday, October 12, 2012

Magento DataBase configuration file


Magento DataBase configuration file location for simple changes, you find that information into the file:
/app/etc/local.xml
<default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[]]></password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>

Tuesday, July 3, 2012

Get Blog Notes: Facebook share button on your website:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><a href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank"><img src="/images/facebook.png" alt="Share on Facebook" /></a>