celebrate the power and diversity of design

Feel Fabulous Mobile Spa

Logo & Branding / Cards / Stationary
Labels & Stickers / Web Design

Visit Website

Diacarbon Energy Inc.

Logo & Branding / Cards / Envelopes
Web Design / Web Animation

Visit Website

RhondaSherwood.com

Logo & Branding (NOT the ScotiaMcLeod Logo)
Web Design / Wordpress Blog Integration

Visit Website

Alta Pacific Mortages & Investments

Logo & Branding / Business Cards
Booklets & Brochures / Email Newsletter

Website Coming Soon!

Western Global Capital Corp.

Logo & Branding
Business Cards & Stationary

Visit Website

The name of the game: communicating with design. What does this mean to you?

It's about making an impact. It's about getting the message across. It's about following trends & setting new standards at the same time. It's about flow, gusto & charm, with a hint of genius.

Designing businesses since 2005, we have achieved some amazing milestones and we aim to achieve more in the coming years.


Warning: Cannot modify header information - headers already sent by (output started at /home/sonikas/public_html/header.php:4) in /home/sonikas/public_html/blog/wp-includes/feed-rss2.php on line 8
Sonika Studios Inc. » Internet http://www.sonikastudios.com/blog Vancouver Web Design, Branding, Print Design Tue, 20 Sep 2011 18:06:22 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 PHP for HTML Designers to Save Time, Speed Up http://www.sonikastudios.com/blog/tutorials/php-for-html-designers-to-save-time-speed-up/ http://www.sonikastudios.com/blog/tutorials/php-for-html-designers-to-save-time-speed-up/#comments Sat, 27 Jun 2009 09:42:46 +0000 Jeff Kee http://www.sonikastudios.com/?p=46 read more]]]> To some designers who are well versed in graphic design and HTML, but has little or no experience in coding and programming, the idea of PHP may be intimidating. Some people may even say they do not need it within their field. Yes, it’s true that using PHP, you can work database-driven websites with MySQL, and you can work with XML data integration. You can also exchange information between different servers in order to achieve Paypal gateways and what not. BUT some basic PHP can be used simply to save you a LOT of time in coding and updating sites.

For this exercise, you only need to know a few PHP commands. To open a PHP code snippet, you use <?, and to close, ?>. In some cases, opening with <?php is recommended, but I generally skip it – it’s not critical.

Once a PHP command is opened, here’s some basic commands. You can also look at this PHP Tutorial on W3Schools.com.

$: The dollar sign ($) denotes a variable. You can store any value you want to use later in the page, and use it repeatedly. For example,

$myName = "Jeff Kee";

This code stores the string “Jeff Kee” into the variable $myName. Note that ALL PHP LINES MUST END WITH ;. You can put multiple commands in one line, but each command MUST END WITH a ;. The exceptions are loops, but that’s too advanced for this tutorial.

echo: The echo command literally echoes out what’s typed out. You MUST enclose all strings in quotation marks, OR type in variables.

<title><? echo $myName; ?></title>

This would output

<title>Jeff Kee</title>

on your browser! Very simple eh? Now, if you wanted to put some strings together to make it a bigger piece:

<?
$myFirstName = "Jeff";
$myLastName = "Kee";
// the slashes indicate a comment line that is not shown on the browser, nor processed by PHP.
// now we intend to write out your name in a formal format:
echo 'First Name: <strong>'.$myFirstName.'</strong>, Last Name:<strong>'.$myLastName.'</strong';
?>

All that code above, will simply output this:

First Name: Jeff, Last Name: Kee

Simple eh? Note that you can connect strings (the stuff bewteen the ‘ ‘, which are not put into variables and used one-time only) and variables (the stuff that starts with $, which are pre-defined in the first two rows) using the period (.) – it’s like the plus sign (+) in Javascript. Missing the period will cause an error.

include: The include command will include another file (could be .php, or .html.. whatever you want) and put it straight in AS IF THE ENTIRE INCLUDED FILE IS PART OF THE MOTHER FILE. This is very different from calling in CSS files using the <style> tag, or external .js files using the <script> tag. This is literally splicing the code together to PRETEND that all the code was written into one file! You’ll understand this more later.

Now that we’ve covered the very very basics of PHP…

Here is the most common issue I see when I take over a website that was previously managed by somebody who only used HTML:

No inclusion of files!!!

Let’s say you have 10 pages to a site. If they all have the same menu structure, and the same footer structure, you do not NEED to make them all completely separate files. If you do that, you may end up having to change 10 files if you need to add a new menu item, or change some code near the top of the page. The best way I separate files is using header.php, page.php, and footer.php. Having a settings.php file as well as start.php and functions.php is optional too, which I will expain in another document altogether.

Let’s look at page.php:

<?
$titlevar = 'Company Information';
$descvar = '';
$keywordsvar = 'micromatter, ';

include 'header.php';
?>
 <div id="main_content">
 <h2><? echo $titlevar;?></h2>
 <p>MICROMATTER&trade; is an operating division of Advanced Applied Physics Solutions <a href="http://www.aapsinc.com/" target="_new">(AAPS)</a> and specializes in thin film  deposition technologies. </p>

 <p>AAPS is a nationally designated Centre of Excellence for Commercialization and Research, established by <a href="http://www.triumf.info/" target="_new">TRIUMF - Canada's National Laboratory for Particle  and Nuclear Physics</a>. AAPS&rsquo; mission is to improve the quality of life of people around the globe by developing  technologies emerging from physics research. To achieve this objective, AAPS collaborates with academic, government, and industry stakeholders to develop promising technologies.</p>

 <p>MICROMATTER Co. was originally founded in 1968 to manufacture <a href="dlc.php">thin carbon foils</a> for the scientific community. Over the  years, the business has expanded to include accelerator target foils  and <a href="xrf.php">X-ray fluorescence (XRF) calibration standards.</a> </p>

 <p>In  February 2009, AAPS acquired the assets of MICROMATTER Co. and is  continuing the company&rsquo;s forty-year commitment to manufacturing  excellence. MICROMATTER&trade; customers will continue to receive  the high-quality products that they have come to rely upon. In addition, the combination of MICROMATTER&rsquo;s unique vapor  deposition methods and AAPS&rsquo; established capabilities in diamond-like carbon synthesis create technical synergies that will accelerate AAPS&rsquo; research and development objectives in several key areas.</p>
 <?
include 'footer.php';
?>
 </p>
</div>

As you can see, this page does not have your typical <html> opening tag. But note that at the very top of the page, I have the section title defined in a variable like this:

$titlevar = ‘Company Information’;

Each of these pages you generate will have a different title to it.

Now let’s look at the header.php file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo $titlevar;?> : MICROMATTER</title>
<link rel="stylesheet" type="text/css" href="micromatter.css">

<meta name="description" content="Micromatter specializes in thin foil deposition technologies. Carbon foils, carbon films, XRF equipment, XRF calibration standards." />
<meta name="keywords" content="carbon films, carbon foils, carbon, diamond-like carbon foils, dlc, custom coatings, XRF calibration standards, XRF equipment, micromatter, aaps, triumf, UBC, Vancouver, Canada, physics, research, scientific research" />

<meta http-equiv="description" content="Micromatter.com, operating division of AAPS, specializing in Carbon Foils, Carbon Films, XRF Calibration Standards, and other technical innovations" />
<meta http-equiv="keywords" content="carbon foil, carbon film, carbon, cyclotron, physics, nuclear, research, lab, lab products, XRF, XRF Calibration Standards, SEM, DLC, Diamond-like Carbon, diamond, imitation diamond, particle strippers, carbon strippers" />

</head>
<body>
<div>
 <div id="banner"><? echo $settings['company']?><br />
 <? echo $settings['address1']?><br />
 <? echo $settings['address2']?><br />
 Canada<br />
 Phone: <? echo $settings['office']?><br />
 Toll Free: <? echo $settings['tollfree']?><br />
 Fax: <? echo $settings['fax']?><br />
 <script type="text/javascript">infoEmail();</script>
 </div>
 <div id="top_nav">
 <a href="<? echo $settings['sitepath']?>"><img src="images/home.jpg" title="MICROMATTER.com Home Page" border="0" style="border:none;" /></a>
 <a href="/company.php"><img src="images/company.jpg" title="Company" border="0"/></a>
 <a href="/products.php"><img src="images/products.jpg" title="Products - Carbon Foils and XRF Calibration Standards" border="0"/></a>
 <a href="/custom_coatings.php"><img src="images/services.jpg" title="Custom Coatings" border="0"/></a>
 <a href="/contact.php"><img src="images/contact.jpg" title="Contact MICROMATTER" border="0"/></a>
 </div>
 <div id="content">

Now you see what looks like the beginning of an HTML file. This file contains the <head> tag, as well as the top portion of the <body> tag that contains the menus and such. By including the header via include 'header.php' as you saw in page.php, you now are sourcing the entire beginning to your pages via one single file. If you need to add a menu item, you simply edit the header.php file, rather than going through all the HTML files you have!

Also note the <title> tag. Having the page section title in each of the pages is a good practice for SEO. However, you’ll wonder how this works if I only have one header.php file. This is where that code snippet comes in: $titlevar = 'Company Information';. Each page can have a different $titlevar assigned to it. And then using the <title><? echo $titlevar;?> : MICROMATTER</title> snippet, you can then have variable page titles fore each section of your site.

Now, you can imagine what the footer.php file will look like:

</div>
 <div id="footer">MICROMATTER is an operating division of Advanced Applied Physics Solutions<br /><br />
<p align="center" style="color:#333;">Copyright &copy; 2009, All Rights Reserved.</p></div>

</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-1422398-14");
pageTracker._trackPageview();
} catch(err) {}</script>

</body>
</html>

In most cases I will be using a superfooter with more linkes in the footer.php. But for the sake of this excercise, I will keep it simple. Note the Javascript at the end, before the end of the </body> tag. That’s Google Analytics code. If you have the typical HTML file only setup, you will have to embed this Javascript as many times as you have files! However by having one universal footer.php file for your site, you only put it in once, and all the pages will have it.

]]>
http://www.sonikastudios.com/blog/tutorials/php-for-html-designers-to-save-time-speed-up/feed/ 1

©2011 Sonika Studios Inc., All Rights Reserved.
Website Design by... well, us. It's part of what we do.

“We are what we repeatedly do. Excellence, therefore,
is not an act but a habit.”
- Aristotle