Postable

Nice easy way to turn code snippets into web friendly stuff: http://www.elliotswan.com/postable/

Postable | Making your code friendly



Pin It
Leave a comment

WordPress: Sorting and Filtering by Custom Field

Okay, having sorted a query by a Custom Field, you’d like to also compare a different custom field is a certain value? Ie, you have custom fields set up for books, want to sort by the custom field author, but only display books of genre ‘Science Fiction?

For example:

<?php $args = array(
  'posts_per_page' => 10,
  'meta_key' => 'author',
  'orderby' => 'meta_value_num',
  'meta_query' => array(
    array(
      'key' => 'genre',
      'value' => 'sci_fi,
      'compare' => '==',
    )
  )
);

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

endwhile; ?>


Pin It
Leave a comment

WordPress: Sorting Custom Fields

If you’re using Custom Fields (such as the ones that can be set up by Advanced Custom Fields, and would like to be able to sort posts using one of these fields, you can do so with meta_key and meta_Value_num.

For example (where field_name is the name of the field you want to sort by):

<?php
$args = array( 
  'posts_per_page' => 10, 
  'meta_key' => 'field_name', 
  'orderby' => 'meta_value_num' 
);

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
  /* Insert your code here */
endwhile; ?>


Pin It
Comments Off

Magento Developing

Okay, finding stuff in Magento, even when you’ve been using it for a while can be a pain. Like today, I had to update the TopMenu, and although I had edited and changed it all before, I couldn’t, for the life of me, remember where it was located. Of course, the page.xml which references its location as core_text, wasn’t overly helpful and in a moment of idiocy I neglected to turn on the various developer tools in Magento.

So here’s how to do this:

1) System > Configuration > Advanced > Developer > Debug
2) Change “Current Configuration Scope” from “Default config” to Website view or Store view
3) Select “Yes” for “Template Path Hints” and “Add Block Names to Hints”

Then:
1) Select “Developer Client Restrictions” within the same Advanced > Developer section
2) Enter in your IP. What this does, is means that whilst you can see all the debugging red lines and paths, the clients or customers (when live) will not.

Lastly, SAVE. And viola. View your site with the template paths hints turned on.



Pin It
Leave a comment

WordPress: Comments Template on Main Index or Archives Pages

Linking to your comments_template in your index, or archives pages and bewildered by the fact that it just doesn’t seem to do anything?

Simple fix, include right before you call it simply add: $withcomments = 1;

For example:

<?php $withcomments = 1; comments_template( '', true ); ?>

Easy fix for an annoying problem.



Pin It
Leave a comment

Magento: Check & Money Order Available Backend Only

This one is a relatively easy one.

First, so that you’re not editing your core files (which could result in your Magento breaking with an upgrade), first set up the file you want to edit in your local directory. You can do this by creating the following directory structure:

app/code/local/Mage/Payment/Model/Method

And copying app/code/core/Mage/Payment/Model/Method/Checkmo.php to the directory you just created above.

Next, right up near the start of the file, just under where it says:

protected $_code = 'checkmo'; 

Add:

 
protected $_canUseCheckout = false;
protected $_canUseForMultishipping = false;

Lastly, turn on this option in the backend. Now, it should appear when you create a new order through the backend, but not on the frontend when a customer purchases.



Pin It
Leave a comment

Magento: Moving Related Products to the Content Block

By default in Magento, the Related Products are setup to appear in the left (or possibly right) sidebar. If this isn’t for you, and you want them to appear in the main content section, either above or below the product view information, here’s what you need to do:

1. Load up the Catalog XML file in your favourite text editor: app/design/frontend/yourthemedirectories/layout/catalog.xml

2. Search for: product_list_related and copy before commenting (or deleting if you are brave) it out from within the reference name=”left”:

<reference name="left">
<!--block type="catalog/product_list_related" name="catalog.product.related"
  before="-" template="catalog/product/list/related.phtml"/-->
</reference>

3. Lastly, scroll up just a little, so you’re at the bottom of the “reference name=’content’” block and paste in your product related block so that it’s below the </block> and above the </reference> like so:

</block>
<block type="catalog/product_list_related" name="catalog.product.related" 
  before="-" template="catalog/product/list/related.phtml"/>
</reference>

4. One more note… if you want it to appear at the bottom of the page rather than the top, change the “before=’-’” to “after=’-’”.

Viola! Simple.



Pin It
Leave a comment

Magento: Removing a link from top links

On Magento, the “quick-access” links usually sit around the top right side of the page, and include such links as “My Account”, “My Wishlist”, “Checkout”, “My Cart” and “Log in”.

Something I get asked frequently to do is to change this list of menus in some way, and like with many things on Magento, it’s never as easy as it should be. Nor is it entirely obviously exactly how to. So here’s how:

1. Open up your favourite text editor (mine is Notepad ++), and within the layouts directory, do a global search for top.links. These are all the links that appear within the menu.

2. To remove a link, simply comment it out, or if you’re feeling really brave, delete.



Pin It
Leave a comment

Magento: Removing dropdowns from Product List Pager

Magento styles the “Sort By” and “Show x per page” with a drop down, however for one of our sites we needed to put these into a link list. The change was easier to enact than I thought (or at least by Magento’s standards). So if you want to do it yourself:

1. Open up template/catalog/product/list/toolbar.phtml, and look for the “Sort By” div. Completely replace the select and dropdown options with:

<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>" >
<?php echo $this->__($_order) ?></a>
<?php endforeach; ?>

2. In the same file, look for the “Limiter” div and replace with:

<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<a href="<?php echo $this->getLimitUrl($_key) ?>"><?php echo $_limit ?></a>
<?php endforeach; ?>
<?php echo $this->__('per page') ?>
</div>

The result:



Pin It
Leave a comment

Shopify: Linking to a PDF in 3 Easy Steps

1. Select “Account” from the menu up the top right. About half way down the page is a ‘show uploaded files” link. Click on this.

Shopify Show Uploaded Files

2. From here you can manage all your uploaded images and other multimedia files. To upload a PDF, select the “Choose File” button beneath the Upload a new file heading.

Shopify Upload a File

3. Once the file has uploaded and appears in the list of uploaded files, click on it and the details of the file will appear on the left, along with a url which you can use on your pages or blog articles.



Pin It
Leave a comment

Sneak Preview – Mrs Press

My latest freelance project is drawing towards a close and is due to go live this weekend. Exciting stuff. Especially for me, having branched off into a new shopping cart platform which I really enjoyed working with. More polished and easier to develop for than Magento, I’ll write more on what I think of this in a future post. But for now, the sneak preview of the new site for Mrs Press.

The site is simple, clean and elegant, with the focus being on the beautiful clothing which really has to be seen to be fully appreciated.



Pin It
Leave a comment

Magento: How to Disable Annoying Admin Popup Messages

If you’re like me and find the pop up messages that greet you on login to Magento extremely annoying, here’s how to turn them off:

Really simple, and should work in most versions of Magento, simply login, go to System -> Configuration -> Advanced and change the “Mage_AdminNotification” drop down to disabled.

Viola. Your Magento Admin is now pop up free.



Pin It
Leave a comment

Handy Stuff

Adding a cute little to your page couldn’t be any easier than navigating over to Copy Paste Character and clicking on the icon you like. This copies it into your clip board and you can paste it where ever you like. Handy, and saves time having to look up the html.

Mad about curved corners but find producing the CSS a little too time consuming? Then Border Radius could be for you. Simply adjust the values at the corners till you get the effect you want, then copy and paste the CSS into your stylesheet. Easy Peasy.



Pin It
Leave a comment

Digital Ecologists

I saw the term ‘digital ecologists’ used to refer to those amongst the population who build on the web and the biologist in me (I did, after all, originally begin my studies with three years of biology, ecology and environmental science) rather likes the term.

The idea of this other world, this digital world full of what ever we choose to create. Not just professionals like me, but amateurs, hobbyists, writers, magazines … (I’ll stop there, but well the list really would go on, because the potential of the digital world really is limitless)… is amazing. All of us working together and stamping our mark on this sprawling jungle.

But never a virtual world, the products and the people behind the sites are very real and I admit that a little of me cringes when I hear people use the term virtual to refer to the web or what I do. Like somehow it means that it is not quite worth as much. That the impact that it can have on our lives is somehow lessened or invalidated by the fact that it is virtual. But it IS very real. People set up stores solely online, people have had their businesses turn around through the use of online marketing and social media. People make friends, date and marry people they meet online. It is now a part of our lives. If I want to hire a plumber, I don’t reach for the yellow pages. I Google. I read online reviews and select based on their website (they, of course have to have one) their prices and hopefully good feed back from their clients. We can make more informed decisions because of this digital world.

And no longer the frontier world it once was with only a few pioneers braving the web. Now, having some kind of online presence is a necessity for any business. Whether simply a one page business card, or a more elaborate full eCommerce store online.



Pin It
Leave a comment

Two Essential and Simple WordPress Plugins

Two really simple plugins that I find invaluable when developing a website within wordpress are:

Regenerate Thumbs

This plugin ‘does what it says on the can’. It allows you to regenerate all your thumbnail sizes en masse, or individually via the media menus. Why is this good? Imagine you are developing a site whilst content is being added and images added to posts, ready for launch and all of a sudden, there is a change of plans, and the “large” thumbnail size is no longer going to be 540 pixels max wide but rather 500 pixels. Or if you are redesigning an existing blog which already has hundreds of images associated with the post and the new design requires a change of size. Without this plugin, you would have to laboriously go into every post, re-upload each image and insert.

Instead, with the Regenerate Thumbs WordPress extension you can change your Media sizes under settings, then select “Regenerate Thumbs” under the tools menu resize them all at once. Keep in mind if you do have a large amount of images, this will take a few minutes to do, but nothing compared to how long it would take manually.

Simply Show IDs

A lot of the time when you’re developing, you need to be able to know the IDs of posts, pages and categories. This plugin makes it so you can see them in the lists of posts/pages/categories, without having to click through to the individual pages. Very nice.



Pin It
1 Comment