Create the Other Pages
PMA05:00
Now that I have my basic page structure down, it’s time to start looking at the other
pages in my site. Working with the styles I’ve already created (and creating new ones
as I need to), I’ll create the following pages in my layout:
• Blog listing, with the sidebars as used in my two-sidebar layout
• Category page, based on the blog listing page
• Project page, with associated images and text
• Project listing, with images and a brief project description
• Contact page
• A 404 (page not found) and 403 (access denied) page
• The home page, with associated blocks and callout areas
This should cover most of the pages that I will be setting up in the Drupal implementation,
and give me more than enough to work with. Many of the pages will feed each
other—for example, my blog listing page will start with my two-sidebar layout, and
change the listing, and then the category page will follow from that. However, the
project pages, being highly image/case study focused, will require special treatment,
including putting some thought into how I’m going to organize the projects,
pages in my site. Working with the styles I’ve already created (and creating new ones
as I need to), I’ll create the following pages in my layout:
• Blog listing, with the sidebars as used in my two-sidebar layout
• Category page, based on the blog listing page
• Project page, with associated images and text
• Project listing, with images and a brief project description
• Contact page
• A 404 (page not found) and 403 (access denied) page
• The home page, with associated blocks and callout areas
This should cover most of the pages that I will be setting up in the Drupal implementation,
and give me more than enough to work with. Many of the pages will feed each
other—for example, my blog listing page will start with my two-sidebar layout, and
change the listing, and then the category page will follow from that. However, the
project pages, being highly image/case study focused, will require special treatment,
including putting some thought into how I’m going to organize the projects,
Single Node Pages with Sidebars
PMA04:58
The point of starting off your template with a node page that doesn’t have sidebars is
this: you will inevitably have a page like this somewhere on your site. And many designers,
well-meaning as they are, end up forgetting this and assume there will be 1–2 sidebars
on the page. As Drupal’s default behavior reflows the text to fill the entire page when
there are no sidebars, this results in these pages having long and drastically uncomfortable
line lengths.
That said, it’s safe to assume that most pages will have at least one sidebar, and that
the sidebars will contain different types of blocks, for example:
• A list of node titles or categories
• Static text or images
• A tag cloud or something similar
• Callout boxes, like a contact form or customer testimonial
Therefore, while I’m working on my node pages, I should also take a look at how these
different types of sidebar blocks will be styled, and how I’ll set up both one- and twosidebar
layouts.
this: you will inevitably have a page like this somewhere on your site. And many designers,
well-meaning as they are, end up forgetting this and assume there will be 1–2 sidebars
on the page. As Drupal’s default behavior reflows the text to fill the entire page when
there are no sidebars, this results in these pages having long and drastically uncomfortable
line lengths.
That said, it’s safe to assume that most pages will have at least one sidebar, and that
the sidebars will contain different types of blocks, for example:
• A list of node titles or categories
• Static text or images
• A tag cloud or something similar
• Callout boxes, like a contact form or customer testimonial
Therefore, while I’m working on my node pages, I should also take a look at how these
different types of sidebar blocks will be styled, and how I’ll set up both one- and twosidebar
layouts.
Storing Complex Data Types
PMA04:31
You can use sessions to store complex data types such as
objects and arrays simply by treating them as standard variables, as this code
shows:
$myarr["0"] = "Sunday"; $myarr["1"] = "Monday"; $myarr["2"] = "Tuesday"; $myarr["3"] = "Wednesday"; $myarr["4"] = "Thursday"; $myarr["5"] = "Friday"; $myarr["6"] = "Saturday"; $_SESSION["myarr"] = $myarr;
Cookies Versus Sessions?
PMA04:30
$_ENV and $_SERVER ?
PMA04:25
PHP sets several variables for you containing information about the server, the
environment, and your visitor's request. These are stored in the superglobal
arrays $_ENV and $_SERVER, but their availability depends on
whether the script is being run through a web server or on the command line.
Name
|
Value
|
---|---|
HTTP_REFERER
|
If the user clicked a link to get the current page, this will
contain the URL of the previous page, or it will be empty if the user entered
the URL directly.
|
HTTP_USER_AGENT
|
The name reported by the visitor's web browser.
|
PATH_INFO
|
Any data passed in the URL after the script name.
|
PHP_SELF
|
The name of the current script.
|
REQUEST_METHOD
|
Either GET or POST.
|
QUERY_STRING
|
Includes everything after the question mark in a GET request.
Not available on the command line.
|
Of those, HTTP_REFERER and HTTP_USER_AGENT are the most important, as you can use these two to
find out a lot about your visitor and then take the appropriate action. For
example:
<?php if (isset($_SERVER['HTTP_REFERER'])) { print "previously was {$_SERVER['HTTP_REFERER']}
<br />"; } else { print "You didn't click any links to get here<br />"; } ?> <a href="refer.php">Click me!</a>
If you load that page in your browser by typing the URL in by
hand, the "You didn't click any links to get here" text is shown because
HTTP_REFERER has not been set. However, if once the page is loaded you
follow the "Click me!" link, the page will reload itself; this time,
HTTP_REFERER will be set and the other message should appear. Although
it can be easily spoofed, HTTP_REFERER is generally a good way to make
sure a visitor came from a certain pagewhether you want to use that to say, "You
can't download my files because you came from another site" or "Welcome, Google
users!" is up to you.
Install Drupal
PMA04:02
Now that you’ve created your database, go back into your favorite browser (I use
Chrome: http://www.google.com/chrome) and go to localhost:8888/d7-demo/install.
php. Choose the “standard” installation profile for now (see Figure 1-8); it will
take care of some basic configurations for you. On the next page, select English as the
installation language. If you need to install it in another language, there’s a handy link
on that screen that will show you how to do it.
Chrome: http://www.google.com/chrome) and go to localhost:8888/d7-demo/install.
php. Choose the “standard” installation profile for now (see Figure 1-8); it will
take care of some basic configurations for you. On the next page, select English as the
installation language. If you need to install it in another language, there’s a handy link
on that screen that will show you how to do it.
Internal link architecture
PMA03:31
Website linking architecture is important when it comes to SEO, especially when your
site has many pages or is continuously growing. To create a sound linking structure for
your site, you will likely need to partition your site into distinct subsections (or categories),
forming a uniform (inverted) treelike structure. Sometimes creating
subdomains can help in this regard. Other times, using XML Sitemaps can help showcase
your most important links.
site has many pages or is continuously growing. To create a sound linking structure for
your site, you will likely need to partition your site into distinct subsections (or categories),
forming a uniform (inverted) treelike structure. Sometimes creating
subdomains can help in this regard. Other times, using XML Sitemaps can help showcase
your most important links.
Long-term content
PMA03:28
If you use Google to search for any word that appears in the English dictionary, chances
are Google will provide among its search results a result from Wikipedia. The English
dictionary does not change much over time. Sites containing English language dictionary
definitions, such as Wikipedia, are well positioned to receive steady traffic over time.
Most computer programmers use Google to find answers to their development problems.
Sites providing answers to such problems can also benefit from this, as they will
receive a steady flow of traffic.
are Google will provide among its search results a result from Wikipedia. The English
dictionary does not change much over time. Sites containing English language dictionary
definitions, such as Wikipedia, are well positioned to receive steady traffic over time.
Most computer programmers use Google to find answers to their development problems.
Sites providing answers to such problems can also benefit from this, as they will
receive a steady flow of traffic.
Creating custom website widgets
PMA03:26
Everything starts with an idea. Creating custom widgets
can be as simple or as complex as required. You can create some website widgets by
simply creating custom HTML pages. Others you can create by utilizing Atom/RSS
feeds, Java applets, and Flash. In this section, we will create a sample HTML-based
widget to illustrate the concepts of link baiting and website widgets.
Let’s suppose you own a site that sells many different brands of alarm clocks. To promote
your site, you want to create your own link bait. Specifically, you want to create
a simple digital alarm clock widget (called Wake Up Service) that any site can link to
or use. When the widget is used on other sites, you specify the condition that your link
must be present to use the widget.
On your site, you also want to ensure that your link bait is highly visible (typically
placed at a strategic location for easy recognition).
Widget promotion and distribution.
You can proliferate your widgets in many ways. You can
do it from your site, you can use a third-party site, or you can employ both methods.
Make it easy for your visitors by offering simple cut-and-paste HTML code such as the
following:
<a href="http://scripts.seowarrior.net/quickpanel/wakeup.html"
target="_new">Wake Up Service</a>
This sample code shows the link to our Wake Up Service widget, which will open in a
new window. For website widgets such as the one we created in this example, you could
also write a small article that will be syndicated along with all of your other articles.
People subscribing to your feeds will be able to read about it and propagate the information
if they find it interesting.
can be as simple or as complex as required. You can create some website widgets by
simply creating custom HTML pages. Others you can create by utilizing Atom/RSS
feeds, Java applets, and Flash. In this section, we will create a sample HTML-based
widget to illustrate the concepts of link baiting and website widgets.
Let’s suppose you own a site that sells many different brands of alarm clocks. To promote
your site, you want to create your own link bait. Specifically, you want to create
a simple digital alarm clock widget (called Wake Up Service) that any site can link to
or use. When the widget is used on other sites, you specify the condition that your link
must be present to use the widget.
On your site, you also want to ensure that your link bait is highly visible (typically
placed at a strategic location for easy recognition).
Widget promotion and distribution.
You can proliferate your widgets in many ways. You can
do it from your site, you can use a third-party site, or you can employ both methods.
Make it easy for your visitors by offering simple cut-and-paste HTML code such as the
following:
<a href="http://scripts.seowarrior.net/quickpanel/wakeup.html"
target="_new">Wake Up Service</a>
This sample code shows the link to our Wake Up Service widget, which will open in a
new window. For website widgets such as the one we created in this example, you could
also write a small article that will be syndicated along with all of your other articles.
People subscribing to your feeds will be able to read about it and propagate the information
if they find it interesting.