Configuring Drupal SEO


Laying the foundation for a search-engine-friendly Drupal site involves a high level of technique and strategy. Drupal SEO out-of-the-box is made easy with a solid groundwork for on-going optimization efforts. However, this only scrapes the surface of what you can do to optimize your site effectively.
The Basics
Site Name - Initially configuring site during installation is the first opportunity to give your site a unique name. Later on, users may modify this name via the Configuration manager. Once set, the site name will automatically appear in the header, page title, browser tabs, and system generated e-mails. Page titles should reflect the brand, and are shown in the SERP for your page. Human and robots both rely on these titles when it comes to identifying the nature of your site.
Slogan - Drupal allows for the display of a slogan next to the site name or underneath logos (along with other areas, depending on the installed theme). Slogans present as another great opportunity to mix in target keywords. This field will factor into your efforts to push ahead in the rankings, not to mention add a little flair to your page.

Configuring Drupal SEO

Adding a slogan to your website is simple:
1. Access the admin dashboard of your Drupal site.
2. Click on the Configuration link on the admin navigation menu at the top of the page.
3. In the System section of the page, click on the link labeled Site information.
4. Enter the text you want to use in the field marked Slogan. 5. Click on the Save configuration button.
Search Engine Friendly URLs
Next on the list is ensuring that your URLs are Search-Engine Friendly (SEF). Optimizing URLs is double value in making site addresses readable for crawlers and surfers. Without some love from the installer, URLs from Drupal will look something like this by default:
http://www.webcommune.com/?q=node/6
Not conducive to human engagement, and especially not helpful in terms of SEO. Much easier on the eyes and circuits alike, is this:
http://www.webcommune.com/portfolio
Luckily, Drupal has got you covered when it comes to being able to produce SEF URLs like the one just above. Clean URLs and the Path module will allow users to create custom, readable URLs. With Drupal 7, the automatic installer will attempt to apply these features during installation. With these enabled, Drupal will generate a URL alias based off the title of the page.
Clean URLs may be accessed from the dashboard by clicking Configuration>Search and MetaData>checking "Enable Clean URLs"
PathAuto may be enabled from the dashboard by clicking on Modules>Scrolling Down to "Path">checking the module>clicking on the "Save Configuration" button

Configuring Drupal SEO

Custom URLs
Plenty of SEO "experts" occupy the Earth, each with their own discrepancies when it comes to Drupal SEO and SEO in general. One thing all agree on, is how URLs influence the way search engines view and inevitably categorize a content item. With your site set to Clean URLs with the Path Module enabled, you will have total control over your URL aliases. Note than automatically generated URLs are able to be modified, and this behavior is encouraged for the purposes of Drupal SEO.
For a holistic view of URL aliases, including the option to edit them, users can click Configuration>Search and Metadata>Selecting URL Aliases. From this screen admins can make edits, and naturally, not forget to save them!

Configuring Drupal SEO

Discussed were the basics of getting your site up and running, and ready for the big leagues. Drupal SEO is an ongoing process, though these steps really set the stage for new sites. The next steps at the top of your list should be setting up Taxonomy, Tagging, Menu Attributes, and other important modules. Drupal SEO is best rounded out and completed with the SEO Checklist Module, available from Drupal.org.
read more

HTML5 and SEO


Since the advent of the first web search engines, designers and developers have struggled with issues of how to increase their placement on a search engine results page.
With the major search engines (Google, Bing, etc.) unwilling to reveal their ranking algorithms - protecting them from "black hat" search engine optimizers attempting to game the system - "white hat" search engine experts must play a constant guessing game to determine which tactics will be most effective.
The continuing development of technologies, from HTML and XML to JavaScript and Flash, has made the pursuit of prime search engine real estate a massive industry in its own right.
The introduction of HTML5 has simplified many tasks, but adds another layer of complexity in this area.

HTML5 and multimedia

For many years, web designers and developers have used plug-ins such as Adobe Flash and Microsoft Silverlight to add audio, video and graphics content to their projects. These plug-ins have enabled professionals to create glossy, eye-catching designs that have attracted visitors and won numerous awards.
However, these sites have traditionally suffered from poor search engine ranking due to webcrawler's inability to index this type of content. Great strides were being made in this area just prior to the death of Flash, but to a large degree, investment in the area of plugin indexing has now ceased altogether.
HTML5 allows for indexing multimedia content, such as menus, audio and video, with new markup tags. The content within these tags can improve a site's search engine ranking. Indeed an HTML5 site consistently ranks higher than the equivalent site built with a plugin; however there is some question as to HTML5' s suitability for all tasks.
Google frequently tells us to build a site for the user, with 'natural' content. We may need to wait for HTML6 for that to be possible.

Chess

HTML5 and link types

In previous years, developers would use the "rel" attribute on their link tags to specify which links that a web crawler should not follow:
<a href="no-follow.htm" rel="nofollow">Don't Follow This Link</a>
In HTML5, new values for the "rel" attribute of the link tag allow us to create a context for a document that, moving forward, should provide greatly improved search results for users:
Alternate allows us to specify alternate content, the same text in PDF format for example, or the same content in a different language.
<link rel="alternate" hreflang="es" href="espanol.html">
Author enables us to link to an author's profile. This is of great benefit on Google if the author is signed up to Google+.
<link rel="author" href="https://plus.google.com/0123456789">
Bookmark lets blogs link to an article's permanent URL, helpful if your articles are usually published on a home page.
<a rel="bookmark" href="http://mysite.com/article.html">Permalink</a>
Help is designed to be used by third party apps to provide access to help files. Not much use on a blog page, but invaluable for web-based apps.
<link rel="help" href="helpfiles.html">
License provides a link to licensing information.
<a rel="license" href="licensing.html">License information</a>
Next and Prev are used when a document is part of a series, giving context to the current page.
<a rel="next" href="page-2.html">Next</a>
<a rel="prev" href="page-0.html">Previous</a>
Search provides a link to a resource that can be used to search through the current document and its related pages.
<link rel="search" href="http://www.mysite.com/mysearch.xml">
The full specification for these attribute values can be found on the W3C site.

HTML5 and ranking

In late 2010, John Mueller of Google remarked that HTML5 is "still very much a work in progress" and that the company is still working on ways to index HTML5 content. However, the company is making a sincere effort to incorporate the indexing of HTML5 content into its newest generation of web crawlers.

Chess

While Google's relationship with HTML5 standards remains in flux, and while Google remains the focus of most SEO efforts, HTML5' s introduction of new content and ways of describing that content is unlikely to offer any real SERP benefits.
However, the merits of allowing more content to be indexed with less effort is not in dispute, and with HTML5 rapidly becoming the new standard for web design it is just a matter of time before HTML5 sites outrank xHTML sites. Webdesigners should be planning for that future today.
read more

Custom Style All Your Form Elements with Pure CSS and No JavaScript


As a designer, being able to style every HTML element with CSS is what I desire, and not having to use additional scripts to do it is an even bigger desire. We already have a good amount of control over text, paragraph fields and submit buttons, but not much control over other form elements.

Custom Style All Your Form Elements with Pure CSS and NO Javascript

This article will show you how to style all form elements and cover which techniques work in which browsers.

Custom Style All Your Form Elements with Pure CSS

Like the title says, we're going to style the following elements with pure CSS and without any JavaScript help:
  • check boxes
  • radio inputs
  • select boxes
  • file upload inputs
  • text area
  • text fields
  • submit buttons
You will need to download this zip file for the element images.

First Things First

Your HTML tag should look like this:
<!-[if IE 7 ]> <html lang="en" class="ie7" > <![endif]->
<!-[if IE 8 ]> <html lang="en" class="ie8" > <![endif]->
<!-[if IE 9 ]> <html lang="en" class="ie9" > <![endif]->
<!-[if (gt IE 9)|!(IE)]><!-> <html lang="en"> <!-<![endif]->
This is Paul Irish's technique to target IE browsers without using hacks. This'll come in handy when we start coding. We're using HTML5, so make sure you have the HTML5 Shiv in your and reset your form elements like so:
input, select, textarea {
margin:0;
padding:0;
font-size:0.85em /* this is optional, I like the fonts a little smaller */;
outline:none;
font-family:inherit; box-sizing:border-box /* make sure you use the other vendor prefixes */;
}

Check and Radio Inputs (works in IE9, FF, O, Webkit)

Let's get started with the check boxes and radio buttons. We'll need the element to precede the check box and radio inputs for this to work properly. Here's the markup:
<input type="checkbox" id="male" /><label for="male">Checkbox</label><br/>
<input type="radio" name="option" id="female" /><label for="female">Radio 1</label>
<input type="radio" name="option" id="female2" /><label for="female2">Radio 2</label>
Notice the "id" variables on the inputs match the for variables on the labels. This allows us to toggle the radio and check inputs by clicking the label itself, which is larger and easier to click with a mouse arrow or a finger. This is the way labels and input fields were intended to operate.
The CSS
This moves the browser's default radio and check inputs out of view:
input[type="radio"],
input[type="checkbox"] {
position: absolute; left: -999em;
}
Now we'll replace them by adding a pseudo element with a background image to our label element. We're adding a pseudo element instead of some padding and a background image to the label itself because the pseudo method allows us to use image sprites. Image sprites cut down on HTTP requests making the site load faster. For the check and radio inputs, I have two images: one for the off state and one for the on state. Each image is exactly 25 pixels by 25 pixels.
Here's the CSS with comments:
input[type="radio"] + label:before,
input[type="checkbox"] + label:before {
content:"; /* this is generated content*/
display: inline-block; /* make this fake elements inline block */
position:relative; /* we need to move the element without effecting the doc flow */
top:0.25em; /* we're moving it slightly down for alignment purposes */
left:-2px; /* we're moving it slightly to the left */
width:25px; height:25px; /* the width and height of the fake elements */
background-image:url(formelements.png); /* the background image sprite */
}
Now we have our images in place, but the background needs to be positioned. If sprites get complicated, you can always open them in your graphics program and measure the distance with a ruler and get the numbers that way. I keep my sprites simple and all the same size so they're easy to calculate in CSS:
input[type="checkbox"] + label:before { background-position: 0 -25px;} input[type="checkbox"]:checked + label:before {background-position: 0 0 ; }
input[type="radio"] + label:before { background-position: -25px -25px;} input[type="radio"]:checked + label:before { background-position: -25px 0;}
The second lines of code say: if the input has a :checked pseudo class, change the background position of the label's pseudo element that precedes it. As mentioned before, this technique only works when the label precedes the input element in the markup. You can learn more about advanced CSS selectors in this great Smashing Magazine article.

Browser Fallback

We want to support our IE7-8 users so we are going to remove the custom styling for these browsers because, while IE8 supports pseudo elements in markup, it doesn't support the pseudo :checked class, so our toggle won't work, and IE7 supports none of these techniques.
.ie8 label:before { display:none; content:none; /*this removes the fake content*/ }
.ie8 input[type="checkbox"],
.ie8 input[type="radio"],
.ie7 input[type="checkbox"],
.ie7 input[type="radio"]{ position: static; left:0; /* this puts the inputs back in their place */
}
For IE8, I noticed some weirdness in the alignment of the input and the label and so I fixed it. It could've been my IE Tester software, so this code is optional. Use and adjust it if IE8's input alignment looks wacky to you.
.ie8 input[type="checkbox"],
.ie8 input[type="radio"] {
position:relative; top:5px;
margin-right:0.5em;
}
[ demo link ]

Select Fields (Works in IE8+, FF, Webkit)

The credit for this technique belongs to: Bovotasan
The problem with select fields are those drop down buttons. There's no way of styling them, so what we can do is hide them. Basically, we'll wrap the select box in a div, make the select box longer than the div and make the div hide the access width of the select box (which is where the drop down button is). Then we'll apply a background image with our own drop down button. Here's the image we'll be using and the markup:
<div class="styled">
<select>
<option>Explorer</option>
<option>Firefox</option>
<option>Webkit</option>
</select>
</div>
Here's the CSS:
div.styled {
overflow:hidden; /* this hides the select's drop button */
padding:0;
margin:0;
background: white url(formelements-select.png) no-repeat bottom right;
/* this is the new drop button, in image form */
width:12em; border-radius:2px;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
border: solid 1px #ccc;
}
Now we remove any styling from the select box within in the div:
div.styled select {
width:115% /* this percentage effectively extends the drop down button out of view */;
background-color:transparent /* this hides the select's background making any styling visible from the div */;
background-image:none;
-webkit-appearance: none /* this is required for Webkit browsers */;
border:none;
box-shadow:none;
padding:0.3em 0.5em; /* padding should be added to the select, not the div */
}
This technique doesn't work in IE7, so you'll have to remove the styling from the div and apply it to the select box itself. Basically you'll have to fallback to standard styling for IE7. IE7 Doesn't support background images on select either. IE7 is the new IE6.
.ie7 div.styled {border:none; }
.ie7 div.styled select {
width:100%;
background-color:white;
border: solid 1px #ccc;
padding:0.3em 0.5em;
}

File Upload Field (Webkit only)

Adapted from but credited to: The Computer Whiz
Now the file upload field is the most difficult to style, but it is very customizable in Webkit. I originally had a method of creating an upload button and placing it on top of the default button using a pseudo element for Webkit only, but the Computer Whiz method is much better. When I came across it, I decided to use it, but with a few changes of my own. Here's the markup:
<input type="file" />The CSS
This styles the text box:
input[type="file"] {
position: relative /* this needs to be in place for the pseudo element to position properly */;
-webkit-appearance: none /* this is the key to clearing the default styling */;
width: 40%;
padding:0;
background-color: #f5f5f5;
box-shadow: inset 0 2px 3px rgba(0,0,0,0.2);
border:solid 1px #ccc;
}
This removes the default file upload button:
input[type=file]::-webkit-file-upload-button {
width: 0;
padding: 0;
margin: 0;
-webkit-appearance: none;
border: none;
}
This styles the upload file button, you can even change the wording.
input[type="file"]:after {
content: 'Upload File';
margin:0 0 0 0.5em;
display: inline-block; left: 100%; position: relative;
background: white url(formelements-select.png) no-repeat center left;
padding:0.3em 0.5em;
border: solid 1px #ccc;
-webkit-appearance: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
The Computer Whiz has knowledge of Webkit prefixes that I don't, so I began searching for an exhaustive list. Although this is a good page, I don't feel it's exhaustive. If you know of any other lists, please let us know. As Chrome has become the second most used browser, just behind Internet Explorer and passing Firefox, these extensions will come in handy when styling elements of any kind in Chrome.

Text Fields and Buttons (all browsers)

Most of us already know how to style these elements, but just in case you don't, here's the code. Of course the box shadows don't work in IE8 and earlier, so you'd either have to setup a conditional style or live without the special effects. I tend to go for the latter. Less code is better. Here's the HTML:
<input type="text" placeholder="Enter some text here" /><br/>
<textarea placeholder="Enter some words here" ></textarea><br/>
<input type="button" value="&laquo; Previous"> <input type="submit" value="Send &raquo;">
The CSS
For text fields and text boxes:
input[type="text"], textarea {
width:12em;
border-radius:2px;
border: solid 1px #ccc;
padding:0.4em;
background-color: #f5f5f5;
box-shadow: inset 0 2px 3px rgba(0,0,0,0.2);
}
With HTML5 forms can have new text attributes. The widely used ones are: telemail and number. These can be styled just as the input text field and can be selected using the below CSS:
input[type="tel"],
input[type="email"],
input[type="number"] {
Your styles here...
}
For submit buttons
input[type="submit"], input[type="button"] {
background: white url(formelements-select.png) no-repeat center left;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
border-radius:4px;
border: solid 1px #ccc;
padding:0.3em 0.5em;
}
Note: For newer CSS3, make sure to include the vendor prefixes for Firefox and Webkit/Android users still on Gingerbread 2.3.

Bonus: Making the form fields responsive

First of all, let's make the form fit the viewport on mobile devices. Put the following meta in the head of the document:
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>The CSS
I keep my media queries in the same CSS file - right at the bottom. The following code says: If the view port is 600 pixels wide or less, change the body font size (which cascades) to 15 pixels. Because of mobile screen sizes, it's good to make the text a little smaller. The second query says: if the view port is 400 pixels wide or less, make the form elements' width 100%.
@media screen and (max-width: 600px) {
body { width:80%; font-size:15px; }
}/* end of query */
@media screen and (max-width: 400px) {
input[type="text"], select, div.styled { width:100% }
}/* end of query */

Conclusion

If you're having trouble with the media queries working in Firefox, depending on what add-ons/extensions you have installed to make Firefox better, these may prevent you from testing the responsive site. The solution is to disable your add-ons until you find the one that's causing the problem. Or it could be Firefox's menu bar: you might have to change the way it's displayed to resolve this issue.
read more

Legacy Browser Compatibility for HTML5


As long as Internet Explorer will be around holding onto their share of the market in the world of legacy browsers, you'll have to face the facts and develop your CSS to work around versions of Internet Explorer 7 and 8. We have had a ray of hope with the shunning of Internet Explorer 6 as it has now begun to join Netscape in the graveyard of browsers past.
I understand, getting Internet Explorer to comply can be infuriating at times. And I've had to take a stance against developing in Internet Explorer 6, as we all should, but there is help and I hope this article points you where you need to go. One of the first steps when putting the project together is figuring out what browsers you need to develop for. If you ask the client, 9 times out of 10 they'll say "All the browsers!". You'll need to take a step back and examine who their target audience is. Are most of their users tech savvy and use modern browsers like chrome? OR will their users be accessing the site, often at work, behind some sort of firewall system, and forced to endure a browser like Internet Explorer 7 or 8 due to corporate security reasons?
Chrome, while great, at times can make us see our sites through rose colored glasses. It understands HTML5 tags, has little to no compliance issues, and makes everything right the first time. A lot like a warm development security blanket. Depending on how you built your site, particularly in this case dealing with WordPress, there is a good chance that everything will not be as kosher when you view it in Internet Explorer 7/8. That doesn't mean you'll have to toil day and night trying to sort out all of the compatibility issues, trust me I've been there and done that. Then there is that eureka moment where it all starts to come together.
I will admit it did take some honest feedback and a hard look at how my code was structured and a fair amount of research on a previous project to get it to even look half way decent in Internet Explorer. Instead of sweating the details over positioning and floats, IE likes elements that stack well together. In this case it was a background image in a featured area. I was trying to wrap everything under one .container class when I should have created 3 different stackable divs with a width of 100% and margins left and right to auto. That being said, if your audience will be viewing the site in IE 8 or 7 it might be a good idea to tackle building for those browsers first, then branching out into Firefox, Safari, and Chrome.
In this article, I will be showing you how to make your conditional statements, transparencies, and fonts renderings help make Internet Explorer 7/8 more compliant browsers. The use of conditional tags to target specific browser cannot be stressed enough in this article. Much like media queries, the conditional tags that can be found in your <head> section, execute certain variables once met with the condition of the statement. Let begin by structuring a tag:

<!--[if IE 6]>
     <style type="text/css">
          #browserWarning { display: block; }
          <h1 id="browserWarning"> Still using Internet Explorer 6? Don't you think it's time for an upgrade? Download <a href="http://chrome.com">Chrome today.</a></h1>
     </style>
<![endif]-->

<!--[if IE 7]>
     /*Do Something Cool*/
     <style type="text/css">
          #browserWarning { display: none; }
     </style>
<![endif]-->

<!--[if IE 8]>
     /* Do Something */
     <style type="text/css">
          #browserWarning { display: none; }
     </style>
<![endif]-->

<!--[if gt IE 8]>
    <!-->
    /*This is where your HTML tags for modern browsers would go*/
     <style type="text/css">
          #browserWarning { display: none; }
     </style>

    <!--
<![endif]-->

So now you're beginning to wonder "What can we honestly place inside these tags?" It's not uncommon to link to external stylesheets that cater to that specific browser, inline CSS, or Javascript. One that everyone might be familiar with is setting classes with the html tag:
<!--[if IE 7]>
     <html class="no-js ie7" <?php language_attributes(); ?>>
<![endif]-->
Now you can begin to format your CSS in the same sytlesheet, if you so choose, with the prefix class of: .ie7 #wrap { width: 80% }
All of you're IE 7 specific styles should then apply themselves accordingly. If you keep running into issues and your website still looks like a hot mess more than the structured design you envisioned, you'll need to make Internet Explorer recognize several of your linchpin elements in the code.
One snippet of Javascript I've found rather useful creates element names based on the HTML5 tags that you've used. That means you can still utilize the navs, headers, articles, and so forth. It's nothing complex, so let's take a look:
<!--[if IE 8]>
     <html class="no-js ie8" <?php language_attributes(); ?>>
     <script type="text/javascript">
      document.createElement('header');
      document.createElement('nav');
      document.createElement('section');
      document.createElement('article');
      document.createElement('aside');
      document.createElement('footer');
   </script>
<![endif]-->
And almost like magic, your website begins to look consistent between various browsers. You can then begin to use positioning in your main CSS files with with the classes of .ie8 or .ie7 before the CSS property. Like so:
.ie8 .logo {
     width: 200px;
     height: 180px;
     position: relative;
     top: 0;
     left: 0;
     z-index: 2;
}
You should take a moment to toy around with the position and elements till you can get them close as possible if not perfect. As most of us have moved onto greener pastures with our browser choices, there are ways you can test your designs in Internet Explorer 7 or 8. IE Tester, is a good place to start. It is the closest testing environment I've used that mimics how the site will look and all of it's quirks. There's also the cloud based in browser application Browser Stack which allows you to test all of your browsers even mobile browsers. God help us if someone was evil enough to make IE7 for a windows phone.

HTML5 Shiv

HTML5 Shiv or 'Shim' targets browsers older than Internet Explorer 9 in the same regards as the above Javascript. Shiv allows older versions of Firefox, safari, and Internet Explorer to read HTML5 tags and you can style them through the CSS. The only major difference between using this and the code above is the method of implementation.
You can download HTML5 Shiv from the GitHub repository maintained by Alexander Farkas, Johnathan Neal, and Paul Irish.

Transparency and PNG images

Both versions of Internet Explorer 7 and 8 have native support for transparency, but it often falls short of what you need. You can either face what is called the 'black-halo' when you set your opacity to 100%. Granted it can be removed when you remove the alpha properties, but what about gradients, etc.? This is where 'filters' play a role in our CSS. Let's take a look:
.logo {
     background: transparent;
     filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=logo.png, sizingMethod='crop');
}
In the above example we've set the background of our div class to transparent, then introduced a filter property. The 2 parameters outline our image source and the method we're using to size it.
If we wanted to utilize a gradient inside of our div, we use a filter that is a not more complex than the Alpha Transparency. All your doing instead of calling the source and size in the filter, you are calling your starting bottom color #90B4B2 to your top ending color #D7EEED.
.logo {
     background: url('logo.png'); background-repeat: no-repeat;
     filter: progid:DXImageTranform.Microsoft.gradient(startColorstr=#90B4B2, endColorstr=#D7EEED);
}

Quick Fix

If you need go back even further, there is hop in the form of the pngfix.js file from Bob Osloa. This JS file has been around a while as a response to the poor PNG rendering methods of Internet Explorer 6. I feel that the script itself still holds up today.

Font Rendering

In the several cases I've seen you can run into issues as well with ClearTypes. ClearType was introduced as a technology to improve the readability of text on LCD's by Microsoft. Using ClearType with a background fill is best for that situation that way your fonts can appear as intended in the browsers.
It's really a matter of choice. You can opt not to use ClearType, but those of you reading this that tend to be shall we say a bit "retentive" with the sites that you produce, such as myself, go for the ClearType with background fill option.
Hopefully if this article does not help you resolve the Internet Explorer compatibility issues your facing, I hope I could have at least provided you with a stepping stone. Using the methods and tools in this article can help save you hours or literally days of compatibility development time and a headache or two. Remember to keep your headache medicine close.
If you have any questions please leave them in the comments and I will respond to them promptly.
read more

PHP to Static HTML On The Fly


Data driven web sites are da bomb, in my not-so-humble opinion. The ability to drive information through a slim passage and have that information display, in various ways, is without a doubt amazing. Anything can be manipulated, altered, structured, added, removed and decided before it even hits the screen. Systems like WordPress, Joomla, Drupal have had their day in the sun. On the horizon are even more progressive, minimalistic UCGm [User Generated Content management] systems that will have all of us programmers gushing like school-boys. Old[er] folks, like myself, who worship L, M, W -AMP need to sharpen our skills, keeping marathon pace with the wondrous changes in the digital universe.
Recently, I was faced with a serious issue for a clients website, where -due to their server set up- and limited ability to get noticed by the Big3 Searches. If fact, with the Panda/Penguin frequency and alterations for "YingBook" {yahoo, bing, facebook} social search, the site all about keeled over. The problem was: her pages were getting ignored or the database would go offline for exceeding the 128 limit. Evn after increasing to 256 the site was still @ a snails pace. Not to the point of tears, she asked me why she could not just create Static pages like the old days {html4}, using the current CMS platform.
My explanation was nothing short of a technical plethora, of which she was oblivious. Finally, I said to her, "We can set up a system to transfer all your data based pages into static html, that you can edit on-the-fly. Long story short, as a marketing "gurette" of sorts, is now working with me to develop a strategy to offer the general population such a program -primarily for mobile/wireless devices like iPad, Android maybe even SUR.
The PHP to static HTML works quickly and effectively, to take the information and create  fully functional, SEO friendly pages, without the trapped header or slugs limitation often associated with CMS programming. It can even include breadcrumbs or anything, really, that fits into a traditional web page. I first used this approach for rebuilding RSS Feeds ala minute as pages were changed/updated, created or deleted from the system. A very efficient, lightweight measure, that truly boosted visibility, while providing an outlet from the data doldrums and easy enough for the novice designer or non-tech to use.
PHP > HTML
  1. Collect Data from Database
  2. Get Static or Template Elements
  3. Parse PHP to HTML
  4. Reload Sitemap/RSS

Database Checkpoint - Update or Create?

Simple and easy. Get the post Title, etc. Do the error checking, like empty, too short or too long. Apply the errors for all the additional items like photo, video or audio formats (extensions), content word count, etc. Once complete, we execute two options. Does this Title exist? If yes, update the record by this author, back-up the old page into a zip file, unlink the old page, create a new page and reload the RSS feed. Else, add the new record to the database, create a new page and reload the feed.
/* Check for Errors */
$TITLE=$_POST['TITLE'];
if($TITLE=="") {die('Title cannot be empty');}
else {
$skunk=array('+','-','_','!','?','...','*','&','%','=','~');
$TITLE=str_replace($skunk,' ',$TITLE);
$TITLE=str_replace('  ',' ',$TITLE);
}

if(strlen($TITLE)<12){
die('Please make the Pubtitle more than 12 letters');}
elseif(strlen($)>40){
die('Please make the Pubtitle less than 40 letters');}
else {
$TITLE=strtolower($TITLE);
$TITLE=ucwords($TITLE);
}

/* Check Title Database */

$title_chk=mysql_query("SELECT * FROM `PUBS` WHERE TITLE='$TITLE'")
while($row=mysql_fetch_array($title_chk)){$TITLEX=$row['TITLE'];

if($XTITLE==$TITLE){
UPDATE TABLE WITH NEW INFO

/*Zip old File*/
$zip = new ZipArchive();
if($zip->open('$TITLE-$date.zip', ZIPARCHIVE::CREATE) !== TRUE)
{die ("Could not open archive");}
$zip->addFile('../pubs/$TITLE', ''.$TITLE');
$zip->close();
unlink($TITLE.html);
CREATE NEW PAGE BASED ON UPDATE;
RELOAD RSS }
} else {
$new="INSERT INTO `PUBS` (TITLE, SCRIBE, ETC)
VALUES ('$TITLE','$SCRIBE', ETC)";
$result=@mysql_query($new);
if(mysql_affected_rows()==1) {

CREATE NEW PAGE BASED ON UPDATE
RELOAD RSS
}

Static Page Creation

This can often be done using the Get_File_Contents function, which will grab elements from an existing Template and APPEND new information to the Static Page. But, I find this can be tedious work, especially since it requires breaking apart the template and rebuilding the elements on a line by line basis. So, to speed up the process, my approach is to start with a completely fresh page. By doing so, I create new headers and meta, then  transpose the entire content of the page. This allows MASSIVE flexibility as to what items will be displayed. As a big fan of jQuery .load('page.html') function, the items necessary to perform certain functions already exist off page, thereby reducing digital clutter.
/* create master page per Title */

$HTML=$TITLE.'.html';
$handlehtml=fopen($HTML, 'w');
$loadhtml='
<!DOCTYPE html PUBLIC>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>'.$TITLE.' |  MY KEWL WEBSITE</title>
<meta name="description" content="$SCRIBE"/>
<meta name="keywords" content="$PHOTO1, '.$KEYWORDS', ETC"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="author" content="AUTHOR"/>
<meta name="revisit-after" content="1 days"/>
<meta name="y_key" content=""/>
<meta name="msvalidate.01" content=""/>
<meta name="google-site-verification" content=""/>
<meta name="alexaVerifyID" content=""/>
<link rel="canonical" href="/img_articles/22131/$TITLE.html"/>

<link href="css/abc.css" rel="stylesheet" type="text/css"/>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jquery.tools.min.js"></script>
<script src="js/abc.js" type="text/javascript"></script>
</head>
<body>
CONTENT ELEMENTS
</body>
</html>
Using this method, we simply re-create a typical HTML page, being certain to include all the header, meta and linked scripts, like CSS and JavaScript. Notice we use a write (w) command versus append (a). This is important, else nothing will be written on he new page. Again, if you have a Template, you can use the append to add the entire <body>CONTENT ELEMENTS</body> being sure to close the </html> before closing or moving the file.
Now, let's say for example, you or the author want a backup of the OLD file before creating a new one. You would create a .zip, .gz or .tar file, drop the old file in and then unlink the old file, before creating the new one. And, again, this is me, very elementary, methodical -almost OCD- when it comes to programming. I am buggered by errors or mistakes, so take a very mechanical/robotic approach to doing functions like these. {A most common error, believe it or not is a missing semi colon or curly brace that would taunt me for the better part of a day}

Handle the Data, Write the Flat File and Close Up {its like digital surgery}


fwrite($handlehtml, $loadhtml);
From here, skies the limit. Add any and every element you prefer, be it traditional html4, xml, html5, etc. Write the $handlehtml and $loadhtml elements into the file. Do not forget to do this, else the system with throw an error. Once the file is complete, reload the RSS Feed/Sitemap file. This is very vital for the Big3 which will pick up the fresh, new page -as an updated version -or brand new version- when the feed reloads (usually every 20 minutes). This enhances the chances of being indexed quickly and when the spider comes crawling, it finds that clean link and new html page in perfect press.
  1. Use the same process to rebuild RSS Feed/Sitemap
  2. Delete the old RSS/XML
  3. Create A New RSS/XML
Handle & Write the Information from the Database ORDER BY DESC 15 -as to force the Updated or New Page to be first on the list!  Add whichever additional headers to redirect to the New Static HTML page, trigger the Old Title.zip for download, or revert back to the authors account.
Did I mention PHP is da bomb ? Huzzah!
read more

How to Slice Images into Tiles with jQuery and CSS3 Transitions


Did you ever wonder how those cool slideshow plugins split images into pieces and put them back together? This tutorial will get you a good understanding of the basic concept behind this effect as we build a simple jQuery plugin.

How to Slice Images into Tiles with jQuery and CSS3 Transitions

Check out the demo to see the tiles effect in action.

How to Slice Images into Tiles with jQuery and CSS3 Transitions

Project Setup

The first thing we need to do is to create a folder to hold our project. Let's name our plugin "sliced". Next, create three files,index.html,jquery.sliced.css and jquery.sliced.js. Grab this basic HTML template and copy/paste into index.html just so it's quicker to get started. Then download this image and put it in your folder. Now we're ready.
Let's create some initial markup:
<div class="sliced">
<img src="img01.jpg"/>
</div>
For the effect to work properly we need to set the dimensions of the container equal to the dimensions of the image.
.sliced {
position: relative;
width: 640px;
height: 400px;
}
Next, setup a basic jQuery plugin boilerplate:
;(function( $, window ) {
var _defaults = {
x : 2, // number of tiles in x axis
y : 2, // number of tiles in y axis
random : true, // animate tiles in random order
speed : 2000 // time to clear all tiles
};
$.fn.sliced = function( options ) {
var o = $.extend( {}, _defaults, options );
return this.each(function() {
var $container = $(this); // cache selector for best performance
// Code here
});
};
}( jQuery, window ));

How the Effect Works

The key to achieve this effect is background-position. Each tile is a div with the original image set as background and the background-position is calculated by getting each tiles' offset in relation to the parent container, using jQuery's .position(). Let's visualize it first:
You can fiddle with this CSS only demo to really understand how the effect works before abstracting the code.

Creating the Tiles

All the code from here on goes inside the return this loop.
First let's declare all the variables and elements that will be used to build the tiles.
var width = $container.width(),
height = $container.height(),
$img = $container.find('img'),
n_tiles = o.x * o.y, // total number of tiles
tiles = [], $tiles;
Next, we need to create all the wrappers for the tiles:
for ( var i = 0; i < n_tiles; i++ ) {
tiles.push('<div class="tile"/>');
}
$tiles = $( tiles.join('') );
// Hide original image and insert tiles in DOM
$img.hide().after( $tiles );
Now that the all tiles are in the DOM we can set the dimensions and the background:
// Set background
$tiles.css({
width: width / o.x,
height: height / o.y,
backgroundImage: 'url('+ $img.attr('src') +')'
});
// Adjust position
$tiles.each(function() {
var pos = $(this).position();
$(this).css( 'backgroundPosition', -pos.left +'px '+ -pos.top +'px' );
});
Finally float the tiles in jquery.tiles.css. This could be done in JavaScript but is better to keep our logic and styles separate:
.tile { float: left; }At this point if you call the plugin on the container and inspect the markup with the browser you can see that with so little code we already have a prototype that works. Here's the plugin so far.
$('.sliced').sliced({ x:4, y:4 }); // Split image in 16 tiles

Animating the Tiles

Every single tile needs to start animating at a certain point in time. For example, to animate 4 tiles in 2 seconds each tile needs to be animated for half a second and the delay will increase by half a second every next tile until all tiles have cleared.
We need to loop all tiles somehow; the first thing that comes to mind is a for loop . We could write something like:

var tile, i;
for ( i = 0; i < n_tiles; i++ ) {
tile = $tiles.eq( i );
}
The above approach is alright but it doesn't provide a way to randomize the order in which the tiles are chosen to be animated. So yes, it works, but it's not ideal.
After much experimentation I found a simple way to get a range of numbers in random order:
/**
* range Get an array of numbers within a range
* @param min {number} Lowest number in array
* @param max {number} Highest number in array
* @param rand {bool} Shuffle array
* @return {array}
*/
function range( min, max, rand ) {
var arr = ( new Array( ++max - min ) )
.join('.').split('.')
.map(function( v,i ){ return min + i });
return rand
? arr.map(function( v ) { return [ Math.random(), v ] })
.sort().map(function( v ) { return v[ 1 ] })
: arr;
}

With this little function you can pass a minimum and maximum value and it will return an array with all numbers in the given range. If the rand flag is set to true it will shuffle the array. Try it:
console.log( range( 0, 5, true ) ) //=> [ 0,2,5,3,4,1 ]Since this function doesn't depend on any jQuery code we should move it outside the plugin, at the same level where _defaults is declared.
Now that the tiles can be looped however we want let's use setTimeout to control the delays:

var tilesArr = range( 0, n_tiles, o.random ),
tileSpeed = o.speed / n_tiles; // time to clear a single tile
tilesArr.forEach(function( tile, i ) {
setTimeout(function(){
$tiles.eq( tile ).fadeTo( 'fast', 0 );
}, i * tileSpeed );
});
At this point if you try the plugin it will animate the tiles' opacity in random order as soon as the page is loaded but we want to have some control over this. This indicates the need for a public method. The simplest way to expose some code to the user is to create a custom event:
// Public method
$container.on( 'animate', function() {
tilesArr.forEach(function( tile, i ) {
setTimeout(function(){
$tiles.eq( tile ).fadeTo( 'fast', 0 );
}, i * tileSpeed );
});
});

Now when we call $('.slider').trigger('animate') the animation will begin.

Using CSS3 Transitions

So the basics are working, wonderful! but we want to have even more control. Instead of using fadeTo let's add a class to the tiles when they are animated, that way we can use CSS transitions with our new class. We'll use toggleClass() instead of addClass() so the effect can be toggled back and forth by just calling the animate method on a button for example.
$tiles.eq( tile ).toggleClass( 'tile-animated' );Now, create a very basic opacity transition in CSS. For brevity only the unprefixed properties are used but you'll need to add the appropriate vendor prefixes in production.

.tile {
float: left;
opacity: 1;
transition: all .3s ease-in-out;
}
.tile-animated {
opacity: 0;
}
Last but not least, we need to prevent the CSS3 transitions from animating on page load. To fix this we can add a class to the body of the document while the contents are loading and then remove that class once the DOM has finished loading. This code doesn't depend on the plugin so let's add it before the plugin.
// Prevent css3 transitions on load
$('body').addClass('css3-preload');
$( window ).load(function(){ $('body').removeClass('css3-preload') });
Then cancel the transitions in CSS:
.css3-preload .sliced * {
transition: none !important;
}

Note: Run the plugin on document.ready() and not on window.load() otherwise the fix won't work properly.

Conclusion

Thanks to CSS3 transitions the effects that can be achieved with this approach are almost endless. A whole new effect can be created with just a single line of CSS, for example transform: rotateZ(360).
If you want to see what's really possible check out jquery.tiles, a jQuery plugin I recently released that creates a slideshow with a bunch of cool effects using the technique shown in this tutorial.
Note: Browser support is wide, we're only using CSS so it should degrade gracefully. Since the plugin takes advantage of some ECMAScript 5 methods such as map and forEach browsers that don't support these will need a polyfill like es5-shim or similar. Jquery's $.map and $.each could also be used but the native methods look cleaner and can be chained.
read more

Create a Glossy Photo Effect with CSS3


More and more we find ourselves creating effects that would normally be done in design software like Adobe Photoshop, using just CSS. And more recently the new effects achievable with CSS3.

Create a Glossy Photo Effect with CSS3


In this tutorial I'm going to show you how to recreate this common effect of making a glossy image, by using some CSS3 gradients.
HTML Structure

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Glossy Gradient Effect</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<div class="photo">
<img src="images/bag.jpg" alt="Bag">
</div>
</div> <!-- END Wrapper -->
</body>
</html>
CSS Styling
General
body {
background: #EDEFF4;
}
#wrapper {
margin: 30px auto;
width: 600px;
}
Styling the photo container DIV
.photo {
margin: 30px auto;
height: 401px;
width: 602px;
position: relative;
-webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 2px 3px rgba(0, 0, 0, .5);
-moz-box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 2px 3px rgba(0, 0, 0, .5);
-o-box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 2px 3px rgba(0, 0, 0, .5);
box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 2px 3px rgba(0, 0, 0, .5);
}
.photo img {
border: 1px solid rgba(255, 255, 255, .1);
}
Styling the :before pseudo element of the photo
.photo:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, .15)), to(rgba(0, 0, 0, .25))), -webkit-gradient(linear, left top, right bottom, color-stop(0, rgba(255, 255, 255, 0)), color-stop(0.5, rgba(255, 255, 255, .1)), color-stop(0.501, rgba(255, 255, 255, 0)), color-stop(1, rgba(255, 255, 255, 0)));
background: -moz-linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), -moz-linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));
background: linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));
}

Conclusion



Okay, so for this short mini-tutorial, we're going to be using a very basic HTML5 setup. With the least amount of things possible, for this effect wants to be achieved using mainly CSS. Therefore it's best practice to keep the HTML as clean and semantic as possible.
So apart from the page structure and wrapper, we basically have just one DIV element (with a class of photo) that we've stuck an IMG tag inside of.
That's it for the HTML! So let's get onto the CSS side of things.
First of all we'll just set up the page so that we can concentrate on the photo element. Here we are just adding a background colour to the whole page, and setting up the page wrap DIV.
Next step is style the containing div. So here we're specifying the height and width of the block element. This is the most important point in this step, that and setting the position value to relative. Everything else is purely for aesthetic purpose. Like the cool double box shadow around the whole image, and the 1px border.
Now the image looks good. But we're missing one thing, the gloss effect itself. That's the last step in this mini-tutorial.
Here's the most important step of the whole effect, we're going to style the :before pseudo element of the div. That way we can add the style of the glossy look over the top of the photo without having to add extra markup in the HTML side of things. That way it's more semantic. Here we're absolutely positioning this element over the photo (that's why it's important to set position: relative; in the step above), and we're applying some CSS3 gradients to the background of this new pseudo element.
Now I know that all those numbers might be quite scary looking for beginners. But they're basically all RGBa values (color values that we can apply opacity to) inside of "stops" for the gradients. So to describe what's happening .. we have 2 halves of the gradient, going from the TOP LEFT corner, to the BOTTOM RIGHT one. The first half goes from fully transparent all the way to 50% transparent white. The second half goes straight back to fully transparent (that's what creates the diagonal line) and stays that way.

Create a Glossy Photo Effect with CSS3

That's it for this mini-tutorial. Don't hesitate to hit me up in the comments if you have any questions or suggestions. I've put the whole end product up on Github, so feel free to come over and fork it!
I hope you enjoyed this tutorial, and found it useful.

read more
Blogger Template by Clairvo