How to export and import field collection data in Drupal

Hello! There are many great tools out there that make importing and exporting content into Drupal nodes very easy. We deal with custom Drupal content often and have extensively used many of the (amazing) tools available, such as node export, views data export and feed import , specifically with the field collection feeds addon. With all of these solutions, we had limited but no success in exporting our custom content + field collection data. Our field collections contained fields that were configured to store multiple values as an array, which may be why. We never tried the tools that didn’t work with different variations of field options in our field collections. They just didn’t work for us. So we looked into how hard it would be to write our own drush command to easily integrate into our code push system (the system through which code and data is propagated from […]

Create self-populating ajax drop-down forms in Drupal with the Form API

Hello! At risk of making the title of this post a mouth full, I thought I’d share some of our experience with interacting with Drupal’s Form API (Specficially Drupal 7.x). There is a lot of documentation on different ways you can interact with the Form API to accomplish a wide range of tasks from collecting information, processing information or building complex search queries. The latter is where we ventured in our most recent work interacting with Drupal’s Form API. We worked on a project where the requirement was to build a drop-down based filtration system where content category choices in the drop-down boxes would auto populate dependent taxonomies based on the relationship of the taxonomies , content fields and content in general. After choosing all the drop-down boxes, the end-user would then be able to click a “Go” button to build a list of results that apply the selected filters. […]

Use jQuery and CSS to make a sticky navigation menu

Hello! Some may argue that sticky navigation menus (menus that are fixed at the top or bottom of the page as you scroll) are a fashionable web design style. Whether or not its a “fad”, having a navigation bar that is fixed as you scroll throughout the the site is advantageous. This is especially so when you have a page that has a lot of content to scroll through. Keeping the navigation front-and-center as the end-user browses throughout a site will ensure a smooth user experience. Having elements “stick” as you scroll doesn’t have to be just within the context of navigation. You might want to have a sticky newsletter signup, sales chat window or even an e-commerce “cart” block or widget. We thought we would share a simple example that can be injected into any CMS or flat file template. The example includes HTML to generate the menu content […]

Tips to secure your WordPress site

Security is a huge deal. Sometimes your at the mercy of the open source solution or content management system that you choose. There are occasions that even after ensuring your CMS and the subsidiary plugins are consistently up to date, you still fall mercy to a zero day exploit that circumvents the security of your site and allows an attacker to upload a file or modify your backend database. That’s not good! Especially if you are diligent to the best of your abilities. We’ve decided to put together a quick security guide specifically to help people ensure their WordPress implementation is as secure as possible. Web Hosting environment This is obviously a big one. Your hosting environment may or may not be able to provide layers of security as requests to your website are processed and served. There are elements that most web hosting companies should be able to provide […]

Creating custom post types and pulling them into a custom page template in WordPress

Hello! Occasionally in WordPress it is necessary to push, what is primarily a blogging content management system, to its limits in order to create a dynamic website. The reason why it may be necessary to create a custom wordpress post type is in just that scenario where you need to create custom and dynamic types of content that go beyond what a wordpress blog “post” by default will allow you to modify. For example you may want to create a car website that lists all sorts of different cars and has a multiple car listing page and single car listing pages. Each car could have many fields like color, make, model, year, engine, features and so on. Doing this in a wordpress blog post just wouldn’t work because out of the box you only have fields like post title, categories, tags and post content. While it is possible to simply […]

Automatically tweet your Toronto Real Estate (TREB) listings

Hello! A while ago we released a Python based solution to connect to TREB, pull real estate listings and post it to WordPress. We also posted a brief guide on how to use the Python script. With python, we are using the module wordpress_xmlrpc in order to connect to a wordpress sites via the XML RPC interface in order to search, add, edit and delete posts and content. There is tonnes of documentation out there with respect to how you can , via custom code in Python, Ruby or PHP (to name a few), interact with a WordPress site. We are basically taking the CSV data set from TREB, parsing it for certain listings we are really interested in, grabbing the listing photos and then posting it to wordpress as a blog post. For someone with experience in development, this would be fairly easy to set up and integrate into […]

Detect browser type or device type and assign custom CSS in WordPress

Howdy! With the advent of responsive web design in recent years, developing “mobile only” websites has somewhat become a thing of the past. That is to say we no longer need to maintain a separate version of a website for mobile devices as we once did. All that said, it is sometimes necessary to address things on specific devices or specific browsers. A potential scenario could be that a particular jquery plugin, sticky header menu or HTML form may not work in Safari (for example) where it works fine in IE, FireFox and Chrome. There are quite a lot of differences between all the major browsers that any web developer or web designer should be aware of. A scenario we recently had to deal with here @ Shift8 was a particular WordPress sticky / fixed header menu that was overlapping content only on iPhone devices using Safari. A user on […]

Use Python to connect to a WordPress site

Hello there! We love web development here at Shift8. We also love finding ways to automate and integrate different interfaces together. For example, we have written Python solutions to integrate TREB (Toronto Real Estate Board) listings into a WordPress site. Finding a Python Library to work with WordPress There are many readily available libraries that one can use with Python to connect to WordPress’ XML-RPC interface in order to make queries and add/delete/modify content. A personal favourite is the WordPress XML-RPC library that can be easily integrated into python with pip. Simply install the library and you’re ready to start writing scripts to manipulate content on wordpress! Load the libraries in your Python code This is obvious. I’ll provide a snippet that imports all the necessary modules to do pretty much anything in WordPress. #!/usr/bin/python from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc.methods.taxonomies import * from wordpress_xmlrpc.methods.posts import * from wordpress_xmlrpc.methods.users […]

Drupal Development : Make a page template for dynamic page requests

Hello! Drupal is a fantastic content management system with an even more fantastic development community. Recently through our own Drupal development projects, we came across a scenario that required the processing of dynamic (i.e. “Wildcard”) page requests to the same drupal page template. If I’ve lost you already , don’t worry! All we are trying to do is ensure the following page request scenarios are served by the same page template : drupal-site.com/page1/randomrequest1 -> page–page1–wildcard.tpl.php drupal-site.com/page1/randomrequest2 -> page–page1–wildcard.tpl.php You can see in the two above scenarios, that the “page1” root request URI is the same, but the subsequent URI requests , “randomrequest1” and “randomrequest2” are different. What happens if you want to use the same page template for both random requests? Easy, you implement a check in the preprocess page hook in template.php! In your drupal theme, you will have a file called template.php. This is where all the pre, […]

Looking for a way to post Toronto Real Estate listings (TREB IDX) on your site?

Greetings! Are you a real estate agent, or a web designer working to develop a dynamic site that automatically pulls TREB (Toronto Real Estate Board) listings (or TREB IDX) from their database (with their permission of course) and import it dynamically into the site as a regular daily job? We have been working hard to produce a Python based solution to automatically download listing data, get listing photos, and import it into a content management system all automatically! It is fully customizable to import whatever types of listings you desire. Stay tuned and we will be posting an update to this blog very soon with all the detailed information. UPDATE 07/16/2013 Please check out this post to see our latest update on WordPress TREB integration!