Posts Tagged ‘Web development’

Automatically back up your Drupal site’s database

Published by | Friday, February 15th, 2013

You do back up your computer, don’t you? It’s an easy process, even if you don’t use a utility like the Apple Time Machine: you simply move a bunch of files from your one place to another.

But if you try that with your Drupal site, you’ll leave out the most important part—your site’s content and configuration. That’s because those parts live in your site’s database, which is stored far away from the site’s files. The solution is to export the database as a file, then save that file along with everything else. Doing that manually can be a pretty awkward procedure, but the Backup and Migrate module makes it easy. Here’s what I do:

  1. Install Backup and Migrate the usual way (shown in the section “Expanding a Site’s Capabilities with Modules” in Drupal 7 Essential Training).
  2. Define where you want Drupal to store private files by clicking Configuration > File  system. Be sure to secure the destination by following the link on that page. If you don’t, your raw database file could become accessible to everybody.
  3. Configure Backup and Migrate to save the database into that directory. (I set up a schedule to save it once a day.) The video Backing up with the Backup and Migrate module in Drupal 7 Advanced Training shows you how.
  4. Save that database file when you save the rest of the Drupal files.

A conservative strategy: Backup and Migrate set to save six months of backups.

 

One last step: Be sure to practice restoring from that backup to make sure it works, as a bad backup is the same as no backup! Note that this is not the same as a straightforward MySQL export: you’ll need to use the Drupal Backup and Migrate module itself to reestablish your site. But while unusual, I’ve found this procedure to be far easier (and more foolproof) than noodling with my site’s Drupal database manually.

Open source—a two-way street

Published by | Monday, February 11th, 2013

Do you have a favorite open-source software you’re using in your professional work? Most open-source software is created by volunteers, organized as a project where the software is created. If you’re making money from the software, strongly consider giving back to the project.

You don’t have to know how to program to contribute. Answer software questions in discussion forums or social media. Make a financial donation to your project. Many projects would like help with issues peripheral to software development, like accounting, legal advice, marketing or SEO expertise, and more. So get involved and give back to the software you love!

Why WordPress?

Published by | Wednesday, January 16th, 2013

Why WordPress?

 

What makes WordPress a good solution? Why is it so popular? Regardless of the question, the answer is the same, and it can be boiled down to three simple words:

Because WordPress works.

Of course, it’s a little more complicated than that. Let me put it into context from the perspective of the three main users of WordPress: the end user, the site owner, and the designer/developer.

 

 

Easy to find, easy to use, easy to share

A poorly kept secret about WordPress is its findability. If someone asked you how to get indexed on Google and you answered “Just set up a WordPress site,” you would not be far from the truth. The way WordPress is built makes it a magnet for search engines and other online indexes. So much so that if you don’t want your WordPress site indexed, you have to take steps to prevent it from happening.

Out of the box, WordPress has great search and share optimization. With the addition of plugins like WordPress SEO, AddThis, and Facebook for WordPress, these built-in capabilities are further enhanced, giving any site the opportunity to become the next big thing on the web. This is provided the content is great, of course. We’ll get to that later.

The purpose of many websites is to put out easily findable, accessible, and shareable information. And WordPress does this in spades. When you are searching for content on the web today, you will likely find it on a WordPress site. If you are reading or viewing content on a WordPress site, you are able to access and interact with that content through comments and RSS feeds. And once you have read the content, you will have an easy time sharing it with your friends on social sharing sites and social media.

 

Easy to publish, easy to configure, easy to maintain

WordPress is a prime example of the virtues of open source. It is built, evolved, and maintained by the people that use it and is therefore in a constant state of forward-moving flux. For site owners this means by simply running a WordPress site and keeping it up to date, they are at any time using the most current web technologies to communicate with the world.

Over the past three years, WordPress has undergone several fundamental design and development changes that have made an already easy-to-use application even easier to use. At the same time it has become more powerful and diverse. From how it is installed to how a site owner can publish content and interact with visitors, WordPress leads the way in removing the barriers that prevent anyone from publishing online. Between WordPress.com and self-hosted WordPress, most people with access to an Internet connection are now able to publish their thoughts, ideas, and creations online with minimal effort. With the challenges of web technologies all but removed, the site owner can focus on what matters: producing and publishing excellent content to share with the world.

 

Easy to build, easy to augment, easy to evolve

For me, the true power of WordPress lies in the back end. Whether you are a complete novice or a seasoned pro, building themes and plugins for WordPress will make your life easier and will enable you to do more in less time. I am walking proof.

With a design in place, building a custom WordPress site from scratch—one that looks and behaves nothing like what is expected of a WordPress site but is still just as easy to use and maintain—takes less time than with any other platform I have tried. When people ask me what WordPress can do I answer, “Whatever you want it to do.” And I stand by that statement. At its core, WordPress is a simple interface between the site owner, the database, and the end user. All the stuff in between (administration, themes, and functionalities) is available for the designer and developer to play with and add to in any way they want. And because WordPress is open source, people can step in and contribute to the WordPress community in whatever capacity they feel fit, from answering questions in the forums and building free themes or plugins to contributing to WordPress Core.

The bottom line

Though it may sound like I see WordPress as the be-all and end-all of web publishing, the reality is I am a pragmatic platform agnostic. The reason I laud WordPress and why I love teaching people about WordPress is because I see it as one of the best available solutions for most websites today. I have and continue to work with other solutions including Drupal and Joomla!, but for most of the websites I encounter, WordPress is one of the best options.

Whether you are just starting to play with the idea of publishing a blog, you want to become a web designer or developer, or if you already know all there is to know about the web and you just want to play with something new, WordPress is a great tool to use. It has both the ease of use and the advanced features to suit pretty much any need. And when that need isn’t met, a theme, a plugin, or an extension is there to fill the void.

Interested in more?

Suggested courses to watch next:

Introduction to JavaScript templating using mustache.js

Published by | Thursday, December 27th, 2012

Recently I built a small website for an event in my area. This type of project required me to manage small amounts of data—information about speakers, bios, titles, and a description of the talks. I wanted to have a speakers page, but I also wanted a rotating promo built as a component I could use on the homepage, and on other pages to highlight the event’s speakers. That meant two different views for the same data.

This was the kind of problem I used to throw a quick SQL database at, but it really wasn’t worth the pain for this project as the amount of data was so minimal.  However, I didn’t want to resort to HTML because I knew the information would change often and be a pain to update. To solve the problem, I used a library called mustache.js. It’s pretty easy to use, and solves the problem with just a few lines of code.

Why mustache.js?

Mustache is a library that allows you to read in JSON formatted data and display it using templates you design with JavaScript. There are lots of similar libraries, such as underscore.js, handlebars.js, and dust.js. So why did I choose mustache?

I picked mustache because I wanted something simple. Some of the other libraries provide more functionality, but I didn’t need complexity. I needed to spend time building the site, not learning something new. And that’s the great thing about mustache.js—if you know JSON and a bit of JavaScript, it’s a cinch to implement. Although, you do need to know how to use the JSON format, so if you’re not familiar with JSON, make sure you take a look at this article on getting started with JSON for beginners.

Installing or using CDNs

As usual, you have two options for working with libraries. You can install them manually or use CDNs (content delivery networks). Mustache has implementations available for different languages. If you want to download a copy, go to this GitHub page to download mustache.js. Because we’re going to be loading JSON files from an external source, you’ll also need to install jQuery, to download a copy of jQuery you can go to their website.

If you’re just experimenting with the libraries, another option is to load the files from a CDN, a site that specializes in hosting popular libraries like cdnjs.com. In order to keep things simple for this article, I’m going to load things from that CDN.

Our data

Here’s what the structure of my data looked like (abbreviated). It’s just a simple object with an array containing the usual information people would need to find out about the event speakers.

Of course, my JSON file has a lot more information. Here’s the original JSON document with all of the information for this project.

Creating a page

Our page is going to be super simple. I’ll create a basic HTML document, and then create a <ul> tag with an id of talktitles. The list will be empty and will get filled up with data from our JSON file. I’ll also link, in order, to the jQuery and mustache.js libraries from the CDN.

Here’s what that code looks like:

Next, we’ll need to create the template. That’s pretty easy. You create a mustache.js template inside <script> tags. Normally, your page would interpret this as JavaScript and throw an error, but if we give the script a type of text/template, the browser’s JavaScript parser will ignore it. Our template will also need an **ID** because it’s how we’ll refer to it when we use JavaScript to target it.

Crafting our template

Here’s the code for our template. It should go after our call to the jQuery library.

This should be pretty to read. We want to print the titles for each of our speakers. Our template is simply HTML with double curly braces where we want the library to generate code for us. So, to output the title, we simply use {{title}} to output that field from our JSON file. In order to loop through each of the speakers, we use the {{#speakers}} because it’s the name of the array containing all of the speakers.

The reason a lot of these libraries have names related to facial hair is because of the all of the curly braces they use. This technique of putting data from a data file into a template is known as data binding.

Calling the data

To have our data load from the template, we use jQuery’s getJSON method. I can read any JSON file. We can pass the data into a function. We’re using an anonymous function here (a function with no name).

Inside this we can then create a variable called template and then use the jQuery html() method to read the contents of our template into a variable. Then, we use that template and the data with a call to the Mustache.to_html method from mustache.js that will return the HTML with the JSON data merged with our template.

Finally, we use jQuery to place that HTML inside our unordered list with the id of talktitles. Here’s that code:

Putting it all together

Here’s a full listing of the code:

You might have a problem when trying to read the JSON document if you don’t put this code on a server. For security reasons certain browsers (Google Chrome) don’t allow you to load external files on local folders. You can try using Safari, or just load the file on a live server.

The BarCamp Deland website - completed.

My Barcamp Deland project

For the final project, I used a more complicated template to drive the display of different elements on my page. The Featured Speakers rotating promo on the homepage as well as the data in the Speakers page. I also used this on a mobile app for the event, so changing a single text file updated the information in two or three places. You can see an example of the finished Barcamp Deland website for a more complex example of the code.

Investigating web and mobile development job trends using the indeed.com database

Published by | Thursday, July 5th, 2012

One of the ways I monitor what is going on in the web and mobile development industry is to look at job listings. While there are tons of sources to scour, a site called indeed.com conveniently aggregates multiple sources into a searchable trend database that allows you to look up and monitor evolving job titles, skill requirements, and technology trends over time. I was first introduced to indeed.com from a colleague of mine at Adobe whose role required him to monitor evolving and growing job roles to help make strategy decisions on where to take software.

From just a few searches, you can start to get a general picture of some basic findings:

1. Web and mobile design roles

When you do a basic search for job titles like “web designer” and “web developer,” there is clear long term growth, but you also see an interesting recent trend.

indeed.com data chart: web designer vs. web developer.

First let me explain this graph. Out of all of the job listings that indeed.com aggregates (which go far beyond tech positions) the graph shows the overall percentage of jobs that match the search term within the available listings. This percentage is based on the total number of jobs available at the time of sampling, which can go up or down, but shows the overall growth over time of that percentage.

In this case, there has been a slow growth over time for the role of web designer, growing from just under .1% in 2005 to just over .1% today. The web developer role has gone up from .25% in 2005 to just over .4% today. What is interesting to note, however, is that the web developer role has gone down in the last 12 months. While this data doesn’t tell us why the percentage has decreased in the last twelve months, it does provide a quantitative source to start investigating further.

When you consider the growth of mobile, have you ever considered how web roles stack up against mobile roles?

Indeed.com data chart: Web development vs. Mobile development searches

This graph paints a slightly different picture. When you superimpose the mobile role titles of “mobile developer,” “user experience designer,” and “user interface designer” on top of the existing web roles (web designer and web developer), you can see the slow growth in mobile development positions over the last two years. This can form a couple of hypotheses. First, that web developer roles are moving to mobile development. Second, that user experience and user interface design roles are impeding the growth of web design.

While there isn’t enough information to prove these hypotheses, it is an interesting piece of data to monitor, and it may lead you to other sources to prove or disprove your hypotheses.

2. HTML5 v. Flash

One of the things that is difficult to determine with indeed.com is information about very specific technologies, or uses of technology. The indeed.com database is much better at representing large technology areas. One specific area of interest is the perceived growth of HTML5 and the decline of Flash.

Indeed.com data chart: HTML5 vs. Flash technologies

When you look at the data, you see there has been a long-term growth of Flash, but when HTML5 technology needs hit the job market around mid-2009, the growth of HTML5 in job postings grew at a steady pace. When you look at Flash roles, there are nearly three and a half times as many Flash jobs as HTML5 jobs—however, the decline of Flash roles in the last year is at a steeper slope than that of the growth with HTML5.

If you draw trend lines based on the rates of growth or decline in the last 12 months, jobs mentioning HTML5 will overtake Flash sometime later this year.

indeed.com data chart: Flash vs. HTML projected growth

The data that indeed.com has covers up to late 2011. If the rates change has changed since then, then the point of intersection may have already happened, or will happen sooner than this prediction. While this is not a scientific way to look at it, it does provide additional information that can help guide people in their professional development.

3. Content management systems

If you do another data slice around the three major content management systems, Joomla!, WordPress, and Drupal, you can see how they are trending in the job market:

indeed.com data chart comparing Joomla!, WordPress, and Drupal

WordPress is clearly taking the lead in the job market, with Drupal and Joomla following. It is interesting to see that they were all around the same in the middle of 2009, but then WordPress shot up. The division of Joomla and Drupal took place sometime in early 2010.

4. Responsive design

A relatively new trend that is also interesting to map in job listings is responsive design. Responsive design—something that we generally take for granted—is growing quickly. By doing a search on indeed.com, you can start to validate that belief with data:

indeed.com data chart showing responsive design trending

While responsive design within job postings is still a very small percentage, the growth rate has been staggering in the last year, and following this current trend it will continue to grow significantly in 2012.

Wrap up

By looking at job trend data it is interesting to see how roles, technologies, and required skills are changing over time. This information can help inform your professional development, and help you to understand how shifts take place in the job market.

While research like this isn’t scientifically rock-solid, it does start to form hypothesis that you can use to validate against other sources, or take to the community to ask more questions and get additional guidance.

 

Interested in learning more about web or mobile development?
• Titanium Mobile App Development Essential Training
• Mobile Web Design & Development Fundamentals
• HTML5 for Flash Developers
• Create an iPad Web App

Building your web development core skills, and adapting a cross-language approach

Published by | Saturday, May 19th, 2012

Mac Keyboard image.

One question I encounter a lot is whether it’s best for a developer to dabble in a lot of new technologies like SASS, Node, and Rails, or if it’s a better route to specialize in a smaller number of technologies to the point of perfection. Sometimes it feels like the vast number of front- and back-end technologies make it impossible to keep up. This feeling can be especially daunting when you’re looking for a job and it seems like potential employers only want to hire Web Sifus who, on top of having mastered both front-end and back-end technologies, also come with design, video editing, and page layout skills. (If you know that person, or if you’ve encountered a job description like this that only wants to hire Superman—comment below.)

Like all extremes, trying to learn too much, and focusing on too little, are both wrong approaches. Plain and simple, trying to keep up with every language and library is impossible. The goal is not to be miserable trying to learn everything, but to focus on your core and then cross train on skills rather than languages.

Building your Core

For a web developer, a good foundational group of skills to start with are:
1. Setting up and managing a server
2. Building a semantic page structure
3. Mastering page styles
4. Building interaction with the front end
5. Using databases to customize a visitor’s experience

It doesn’t matter whether you’re learning PHP, Python, Ruby, or any other  language you prefer. Learning that some problems are better solved by languages on the server and some on the client is essential. In the end, it’s more important to be proficient at solving problems than slightly more fluent in a specific development language.

After building on your core, it’s essential to make sure you approach projects with a cross-language attitude that stays focused on using the languages you’re comfortable with, and also learning to use different technologies when they make the most sense—not because you feel like you “have to.”

Cross-Language Cross-Training

Cross training in web development means that no one language is an island. You almost never use PHP by itself, or try to solve every problem on a page with JavaScript. Sometimes, the best solution is figuring out how you can combine languages together, and how to decide which language is right for the task at hand.

Recently while working on a Facebook application, I noticed that although there is an SDK (Software Development Kit) for PHP and JavaScript, trying to use just one SDK is silly. It’s better to use both since every language has strengths and weaknesses. For me, web development cross training means taking advantage of that balance and using the best tool for the job.

In the latest episode of View Source, I show you how to use HTML, PHP, and jQuery to upload images to a server and display them on a page as they are loaded. This is a good example of cross training, or, using a combination of skills to accomplish a task. In the video, I use HTML to allow people to upload files, then I use PHP to read the files uploaded to a directory, and jQuery to update the page as soon as a new photo is uploaded so the image uploader can see whether the upload was successful.

Remember, balance is critical to any job. Don’t spread yourself too thin, but also don’t limit your learning so you find yourself struggling with cross-language development. Build your core, then work on your cross-training. While this exercise routine won’t bring you any closer to having six-pack abs, it will make you a better problem solver, and a stronger developer, which will bring you two steps closer to landing your dream job.

 

Interested in more?
• The full View Source weekly series on lynda.com
• All web + interactive courses on lynda.com
• All courses from Ray Villalobos on lynda.com

Suggested courses to watch next:
• Create an HTML5 Video Gallery with jQuery
PHP with MySQL Essential Training
Dreamweaver CS5 with PHP and MySQL