Pinterest for WordPress

Get Dynamic & Get Noticed

Pinterest is the fastest growing social media networks to date – and has already proven to be a powerful tool for driving interest in products or services that ultimately results in buying behavior. So how do you increase the chances of your product going viral in the fast-moving world of Pinterest? One of the best ways is to integrate a ‘Pin This’ widget on your website or blog to ensure anyone viewing it can easily share your engaging content with their friends and the wider Pinterest network.

The Code Snippet

There are several options (and a step-by-step wizard) to creating your own Pin-It button which you should definitely check out. Our sample snippet below is what they’ve deemed the advanced snippet – and we’ve located the Pin Count horizontally, remember to replace anything in italics with your own website’s information.

put this inside your <head> tag
<script type='text/javascript'>
(function() {
    window.PinIt = window.PinIt || { loaded:false };
    if (window.PinIt.loaded) return;
    window.PinIt.loaded = true;
    function async_load(){
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.async = true;
        if (window.location.protocol == "https:")
            s.src = "https://assets.pinterest.com/js/pinit.js";
        else
            s.src = "http://assets.pinterest.com/js/pinit.js";
        var x = document.getElementsByTagName("script")[0];
        x.parentNode.insertBefore(s, x);
    }
    if (window.attachEvent)
        window.attachEvent("onload", async_load);
    else
        window.addEventListener("load", async_load, false);
})();
</script>

put this where you want the button to show up
<a href="http://pinterest.com/pin/create/button/?url=http://www.atomni.com
&media=http://www.atomni.com/image.png&description=This is the sample description." class="pin-it-button" count-layout="horizontal">Pin It</a>

Using WordPress Variables in Pin It Button

Really nothing changes with the majority of the above snippet – you’ll just have to replace the italic text with some WordPress snippets to pull the unique information about your blog posts to be pinned. Here’s what the most basic native-WordPress installation snippet looks like after we replace the italic text with WordPress function calls to pull the unique post data. Each of these are wrapped in a PHP function urlencode() for passing through the URI.

//get urlencode(get_permalink($post->ID)); for the page or blog post's URL
//get urlencode(wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),
 'single-post-thumbnail' )); for the page or blog post's Image URL
//get urlencode(get_the_excerpt()); for the page or blog post's description

<a href="http://pinterest.com/pin/create/button/?url=<?php echo
 urlencode(get_permalink($post->ID));?>&media=<?php echo
urlencode(wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),
 'single-post-thumbnail' ));?>&description=<?php echo
urlencode(get_the_excerpt());?>"
 class="pin-it-button" count-layout="horizontal">Pin It</a>

Depending on what custom variables or other social media plug-ins you’re using this snippet might end up being a bit different for you – just remember to use whatever dynamic information you have about the page, post, or image so it’ll be sure to engage your new audience on Pinterest! This might also be a good time to re-visit how you sculpt your content catalog – how share-able is your content?

Pinterest and SEO

Guess what? This is awesome for search engine optimization too! By using dynamic URL setting as described above you’re creating a new back-link to your website and channel for referral traffic every time someone pins – which means you’ll be expanding your valuable back link portfolio, potentially before your competition. But remember, before someone Pin’s it, they have to find it worth sharing. Make your web content worthwhile, make it aesthetically pleasing, make it count. Compelling content combined with the ease-of-use of the Pin-widget will surely increase your impact on Pinterest.

Google Chrome Passes Mozilla Firefox as #2 Web Browser

The web statistic aggregator StatCounter announced this month that in their most recent pole of global internet browser marketshare, it seems the Google’s Chrome has replaced Mozilla Firefox as the second most used Internet web browser, after Microsoft’s Internet Explorer. While Internet Explorer still maintains a dominant position in the market, its marketshare – currently 40.63% as reported by StatCounter- has been on the decline in recent years as security, cross-browser compatibility, and user-experience issues have eroded monopoly that Microsoft had developed. When combined with Chrome & FireFox’s marketshare – 25.69% and 25.23%, respectively – the top three browsers account for more than 91% of global marketshare, and in the US it is even more concentrated.

In 2012, its important to keep these user trends in mind. Check Google Analytics (or where ever your track your web performance) and monitor your user’s browser preferences. Look for increase in the use of Chrome, and growth in mobile browsers usage as well. As more users use these alternate browsers to access your website, its increasingly important to ensure that your site is cross-browser compatible so you’re brand can be experienced consistently no matter how your stakeholders access the internet.

To learn more about how cross-browser compatibility can improve your web performance, contact atomni.

Magento SSL Validation

Cross browser inconsistencies

Different browsers handle security in different ways. If you’ve obtained and installed an SSL certificate on your Magento website – more than likely you have a few pieces to clean-up before the https:// secure URL will add credibility to your eCommerce site. If there are any security risks (non-encrypted resources) on the page – Chrome will even cross-out the https:// within your URL.
Even worse, this is the description of the above display at Chrome Support is: The site uses SSL, but Google Chrome has detected either high-risk insecure content on the page or problems with the site’s certificate. Don’t enter sensitive information on this page. Invalid certificate or other serious https issues could indicate that someone is attempting to tamper with your connection to the site.

Resolving SSL Issues with Magento

Obviously the whole point of the SSL certificate is to exude reliability and legitimacy – so displaying a broken certificate can sometimes be worse than having none at all.
The primary reason any 3rd party signed certificate is rendered ‘invalid’ is there are http:// references within the source of the page. There are several places to modify Magento’s theme templates to eliminate all references.

1. Go through any static blocks, widgets, or content sections of CMS Pages and either modify absolute links to relative*, ie http://www.yourdomain.com/images/logo.jpg changes to /images/logo.jpg.

2. In /app/design/frontend/yourtheme/template/page/html/ modify footer.phtml, header.phtml, and head.html to change any absolute references to relative references*.

3. In each of the page templates used, located in /app/design/frontend/yourtheme/template/page/ or /app/design/frontend/base/template/page/ all of the references need to be updated. Even references to the doctype and meta information need to be set to https:// references.

If the resource is not located on the same hosting server, use an absolute path starting with https://, if the remote hosting server isn’t secure – you’ll need to download the resource and host it or you’re out of luck.

Magento – Convert Simple Products to Configurable Products Without Data Loss

Magento is a great open-source eCommerce platform that we’ve used in several applications to deliver a great scalable web commerce framework while minimizing lead time. If you’ve got an eCommerce project that you need to get to market yesterday in a LAMP Environment – Magento is certainly on the short list of viable options.

One drawback as you begin to craft the produt catalog, which unless you modify the basic Magento Community installation is essentially the only piece that will make your site unique from any other Magento demo, is that you have to pick what type of Product each Product is – out the gate – and can never change it or get back to that ‘Product Type’ definition screen to change this setting.

This presents non-trivial issues if you suddenly realize you’ve migrated 5,000 different tee-shirts as ‘Simple Products’ and in fact they need to be defined as ‘Configurable Products’ to expose a drop-down on the front-end of the Magento store to select which size an individual will be placing in their cart. Don’t panic, don’t delete all of the products, there is hope for you.

Simply go into the Magento database and upgrade the products! At first glance this may seem to take some tricky SQL with a laundry-list of joins – but do not loose faith in the Magento, it will deliver.

A basic SQL Update changing the product type column in the product entity table from ‘Simple Product’ to ‘Configurable Product’ for all that should be upgraded is all you need, don’t touch any other data - once you’ve completed the data upgrade and attempt to edit any of the modified products in the Magento administrative interface- you’ll be presented with the initial selection screen for Configurable Products and save all of the time, effort, and data already spent on your project.

Just pick which attributes from the applicable attribute set you’d like to expose (remember they have to be available globally AND be of type drop-down), configure the additional information required for a ‘Configurable Product’ and you’ll have drop-downs on the front-end of Magento in no time.

Check out more about atomni, our full line of products, and the great eCommerce Consulting services we offer at atomni ecommerce consulting

Atomni introduces WP-Syndicate

In hopes of making the web a better place for anyone and everyone trying to disseminate their content, atomni has introduced WP-Syndicate, a Code Ignitor plugin that acts as a web distribution technology, letting you publish content from your WordPress blog onto any other website you control – for FREE.

Anyone interested in piping their WordPress blog posts onto their PHP website or other web asset should check out WP-Syndicate. In 3 simple steps, you can have WP-Syndicate installed and configured in your Code Ignitor install allowing you to easily pipe any number of WordPress posts from either the database or rss feed into your website.

If you’d like WP-Syndicate but don’t have the web development expertise to implement it and need some assistance, contact atomni. If you are implementing it yourself and have a general support issue, please contact us at [email protected]

Check it out at www.WP-Syndicate.com

Simple Human Verification with CodeIgniter Form Validation

So not everyone likes Captcha, well, actually I think most people find it minimally annoying. So, while exploring possible substitutes I found a simple Human Verification javascript/php combo, and was able to get it to work with the CodeIgniter Form Validation, to fit right into the submission form without issue.

The Human Verification Script

So this is the source of the original script used below.

The basic idea is to ask the user a simple random question (math or simple recognition) and then check their answer.

The set-up is to put an array of questions and answers in a referenced php file, and have that php file choose one at random and set a $question and $answer variable to be used in the form display.

Continue reading

Magento Product Images Don’t Show Up

There seems to be several interesting steps associated with troubleshooting the first steps beyond the default Magento install. In particular, after you’ve installed a theme and begin to create your own product catalog. The theme for this particular application was from Template Monster and actually built for a previous version of Magento, which in and of itself proved to be a challenge. These are two major issues I ran into and their respective resolutions.

Newly Added Categories or Products Aren’t Showing Up on the Frontend

There are several issue that could be at hand. The best synopsis I’ve found on Stack Overflow. While in the Product editing section (Catalog->Manage Products, and select a product)

1. Make sure all of the products you want to display are in categories
2. On the Inventory Tab, The quantity in stock has to be greater than the ‘out of stock’ minimum quantity, The item has to be marked ‘In-Stock’
4. On the General Tab, The product’s status has to be set to ‘Enabled’ and the visibility has to be set to ‘Catalog’ or ‘Catalog and Search’
5. Once you’ve made sure of these, go go System->Index Management and refresh the product-category indices

Products Show Up, But There Are No Images

This was by far the most frustrating to me. The image files existed on the server, the url’s were identical – but for some reason the images wouldn’t load.
Again, a few steps to troubleshoot while in the Product editing section (Catalog->Manage Products, and select a product)

1. Make sure to recursively change the file permissions in magento/media to ’777′ (full read/write/exec access)
2. On the Images Tab, make sure there is at least one image uploaded for the product, that the Excluded checkbox isn’t checked, and the radios to include it for thumbnail, base image, and small image are selected for the respective images.
3. Under System->Configuration->Catalog->Product Image Placeholders, make sure there is a default image uploaded for each of the respective image types
4. Delete the .htaccess file located in the magento/media folder (thanks rafa)
5. Under System->Cache Management, flush the catalogs image cache.

Navigate to the front-end of your Magento install, and you should see your products with images in the product catalog.

For more great information about Magento, eCommerce Consulting, PHP Development, and Web Best Practices – please visit us at atomni.com, a Philadelphia-based Web Consultancy.

Code Igniter, Active Record, and Chaining where() and or_where()

where(), or_where(), oh where…

Code Igniter is a great PHP Framework for building robust web based applications. CI buys us a boat load of infrastructure functionality right out of the gate. One of the best and most frequently used, is the Active Record library. It allows you to skip the painstaking & redundant building of database queries via string compilation, maintain multiple database connections, and chain selection methods. But, as with any abstraction, you give up marginal flexibility for this ease of use. One of the more notable is the limitations with complex selection statements. One sticky area of note is crafting advanced conditional statements using where() and or_where() calls. Continue reading

My WordPress Was Hacked: musikkorps & “My computer Online Scan”

My WordPress Got Hacked!

So you sit down with your cup of coffee and fire up the Blog for a quick content addition, and you’re prompted with this message from 62.122.72.131:

Warning! Your computer contains various signs of viruses and malware programs presence. Your system requires immediate anti viruses check! System Security will perform a quick and free scanning of your PC for viruses and malicious programs.

Interesting, you don’t remember changing your WordPress page title to ‘My computer Online Scan’, or downloading to run a ‘instal.exe’…but you click cancel and realize quickly you’ve been hacked.

The Problem

Yet another vulnerability of WordPress exposed, through a security hole – a hacker can maliciously embed .htaccess files into the file structure of WordPress. This particular hack has a url rewriting rule sending users to

http://musikkorps.com/mainfile.php

The hole is that to enable WordPress to create Pretty Permalinks, you have to give it write permission to the .htaccess file. This in combination with open file permissions leaves the barn doors wide open for any mal-user to waltz into your WordPress installation and drop dozens of .htaccess files redirecting users.

Putting Out the Fire

musikkorps has added a ton of .htaccess files to your WordPress directory structure, and any valid .htaccess files you did have are overwritten with something like

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)? http://musikkorps.com/mainfile.php

you’ve got to remove them all so either bash into your server and get nifty with command line or pull your entire WordPress install off your server and use folder search to collect all of the .htaccess files. The proper .htaccess file content is

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

They also been so kind as to wipe out the index.php files in all and any of the WordPress themes you’ve installed and replace the code with this redirection script

document.location.href='http://musikkorps.com/mainfile.php';

You’ll have to restore these from back-up or download new copies.

The Long-Term Solution

Don’t use WordPress’s front-end to setup your mod_rewrite rules!

Set permissions to read-only on .htaccess files & index.php files inside themes, learn some regular expressions, and thank yourself later. There is a great resource from WordPress on how to create rewrite rules that will canonicalize permalinks to hit any optimization parameters you desire, http://codex.wordpress.org/Using_Permalinks.

5 Things You Need to Know About Using jqGrid with CodeIgniter

jQuery jqGrid CodeIgniter

When I hear about a new technology, I can’t wait to get my hands on it. Rather than just dabbling around a handful of examples, I tend to gravitate towards things for which I can see a real world application that provides added value and novelty. I recently had such an opportunity and spent a few days building a quite simplistic project management tool using jqGrid. I ran into more ‘gotchas’ and ‘what-have-yous’ than I’d care to remember this soon – most of which had nothing to do with jqGrid or jQuery – and everything to do with the framework I was using, CodeIgniter. As well, these issues did not have solutions commonly available due to the uniqueness of my environment – so I figured I’d share my experience in hopes of saving another poor soul a few hours of tromping through the plug-in bog.

1. Passing Data from Server to Client is Non-Trivial

Native jqGrid uses an encoded URL (GET method) to transport data, CodeIgniter uses POST. This means that you can’t enable CodeIgniter to handle jqGrid without breaking the rest of the CodeIgniter functionality, although uri queries are permitted. So all those cute little examples where the server-side code is simply

$conditions = $_GET[“conditions”];

or

jQuery(“jqGrid”).jqGrid(“setGridParam”,
{url:”+=&qid=”+ currRow.id”});

You can forget about. There is no easy solution to this predicament.

For simple form events, mainly covered by the navigation bar such as add, edit, delete – overriding the beforeSubmit event allows you to in effect circumvent the native posting method and make your own posting call such as:

beforeSubmit:function(postdata, formid){
   postdata[“foo”] = $(“#someFormField”).value;
   $.post(“someUrl.php”, postdata);
   return[true, message];
}

I ended up going with using uri segments to pass information back to the server on the more complex events, such as master-detail grid interactions, because the postdata object is available in the same format for every event type. To achieve this without exposing the data being transferred, and to keep the SEO Engineers quiet, uri routes should be established.

Note:

  • the postdata for a Form Event is the data object of the selected row
  • the postdata for a Grid Event is the pagination and grid id information

Keep this in mind when you are overriding event methods and manipulating the post data object prior to posting back to the server.

2. Leverage the Navigation Bar

There is a lot of time spent on firing off and handling row & cell events in the jqGrid documentation and I’m not sure why. For basic data manipulation the jqGrid already decorates the navigation bar with cleanly themed buttons that show forms for editing, adding, deleting, viewing, and even searching. All you need to do is set the properties to ‘true’ when creating the navigation bar (which only a couple examples fully implement) like this:

jQuery("#rowed2").jqGrid('navGrid',"#prowed2",
{edit:true,add:true,del:true});
  • Note: to correctly post to the server, you’ll most likely have to override the beforeSubmit method for each of these options by replacing true or false with a {property1:value1,property2:value2} list.

It is much better esthetically and programmatically to leverage these built in features rather than adding clunky in-line buttons like the Row Editing -> Custom Edit example available on trirand.

3. Leave Out the Whitespace in the Column Model

I spent too many thought cycles on figuring out why my edit options were not being persisted to the database, only to realize that I was using a set in MySQL and that I had whitespaces between the semicolon and next edit option in my column model.

A quick fix confirmed that jqGrid parses the entirety of the string from the colon after the key value until the semi-colon ending the option value without discretion.

4. Column Model Options are Your Friend

The column model exposes a wealth of customization properties for each field of the jqGrid, two of which are the formatter and edittype properties. Both of these properties generally accept form input types and correctly modify the UI representation of the data to be concurrent. They essentially allow you to make a Boolean field look, feel, and interact via a checkbox.

Although you’ll probably learn it quickly, the formatter property controls the data format within the jqGrid, while the edittype property controls what the data column looks like when an edit, add, or view dialog is displayed.

5. It’s the Documentation, Stupid

The jqGrid documentation wiki is one of the most robust plug-in resources I’ve seen in a long time.

Use it.

I began working off the examples available on the jqGrid Demos page and didn’t realize the flexibility of the package. Sure the interactive examples are fun to play with, but it wasn’t until I really dug into the documentation to make it work in Code Igniter that I realized the customization available in the column model and navigation bar.

I have yet to find an intricate example implementing this technology and I really could not see building a test project to such an extent without hiking up my skirt and jumping into the deep end of the pool.

Various Other Helpful Code Bits

One of the most interesting, and I use that term loosely, things about the jqGrid documentation is that some functionality is described and demonstrated in the jqGrid Demos section of trirand’s site, and some is covered in the jqGrid wiki. It was only by cross-referencing both of these resources that I found all the information I needed.

Get data from currently selected row in the grid with id of list5

var id = jQuery("#list5").jqGrid('getGridParam','selrow');
if (id)
{
var selectedRowData = jQuery("#list5").jqGrid('getRowData',id);
}

To Make a Field Visible in jqGrid, but not Visible (editable) in Form, set the colModel option editable to false.

editable:false;

To Pass data without Viewing Field in jqGrid or edit Form, set the colModel editable option to false, and the hidden option to true. In this way you can inform the page of data about records without being required to expose it to the end user.

editable:false; hidden:true;

For general usage of the jqGrid, there is another useful resource I found here documenting another’s trials and tribulations with jqGrid.