<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Uttammitra's Blog</title>
	<atom:link href="http://uttammitra.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://uttammitra.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 24 Nov 2009 09:16:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='uttammitra.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Uttammitra's Blog</title>
		<link>http://uttammitra.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://uttammitra.wordpress.com/osd.xml" title="Uttammitra&#039;s Blog" />
	<atom:link rel='hub' href='http://uttammitra.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Basic CSS Tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/11/01/basic-css-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/11/01/basic-css-tutorials/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 14:34:58 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=44</guid>
		<description><![CDATA[In this CSS tutorial I will not be able to show you everything there is about CSS, but you will learn how to create nice looking CSS styled web pages. After completing this tutorial, you should have enough information to explore CSS and web design even further. You can download the CSS and HTML files [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=44&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<a href="http://polldaddy.com/poll/2196248/">View This Poll</a>
<p>In this CSS tutorial I will not be able to show you everything there is about CSS, but you will learn how to create nice looking CSS styled web pages.</p>
<p>After completing this tutorial, you should have enough information to explore CSS and web  design even further.</p>
<ul>
<li> You can download the CSS and HTML files we build in this tutorial: CSS files</li>
<li> You can check out what the page should look like here: CSS example page</li>
</ul>
<div>
<p><strong>THINGS  TO REMEMBER ABOUT CSS:</strong></p>
<p>Remember that CSS code is simply written instructions that tells Web browsers (like FireFox and Internet Explorer) how to display things on a page. For example:</p>
<ol>
<li>make text bold.</li>
<li>position things a page.</li>
<li>set the font style for a page or paragraph etc.</li>
</ol>
<p>The sister language to CSS is HTML: code that tells the Web browser WHAT is actually in the page.</p>
<p>&#8230; I know you knew that already, I just wanted to remind you!</p>
</div>
<h2><strong>CSS REDUCES THE NUMBER OF TAGS USED </strong></h2>
<p>Because of the power of CSS, we will be able to reduce the number of HTML tags we use in a page big time, all the while still being able to layout great looking pages using only 6 types (for lack of better words) of HTML tags.</p>
<p><strong>The tags we will use to layout the content: </strong></p>
<p>1. <strong>&lt;h&gt;</strong> The Heading tags which range from <strong>&#8216;&lt;h1&gt;&lt;/h1&gt;&#8217; to &#8216;&lt;h6&gt;&lt;/h6&gt;&#8217;</strong>, are going to be used to mark/tag headings in our pages. So the most important heading will be wrapped in a &lt;h1&gt; tag and the least important in a <strong>&lt;h6&gt;</strong> tag.</p>
<p>An example of a heading:</p>
<div>&lt;h1&gt; <strong>CSS Template Layout </strong>&lt;/h1&gt;</div>
<p>This tells the browsers and the search engines too, that this page is primarily about: &#8216;CSS Template Layout&#8217;</p>
<p>All browsers have a default size (for each<strong> &lt;h&gt;</strong> tag) as to how it renders text when placed between these tags. Many of these defaults can be unusable (especially<strong> &lt;h1&gt;</strong>) because they come out too big. But never fear, CSS is here. We will use CSS to make the text sizes more to our liking.</p>
<p>2.<strong> &lt;p&gt;</strong> The Paragraph tag is used to mark parts of the pages as being &#8216;paragraphs&#8217;, simple enough. Paragraph tags are what they call a &#8216;block element&#8217;; that means that it acts like a block where a space is automatically inserted before and after each &lt;p&gt; tag pair. You see it work in the examples coming up.</p>
<p>3. <strong>&lt;ul&gt;</strong> and <strong>&lt;ol&gt;</strong> List tags will be used to create our menus. The tag <strong>&lt;ul&gt;</strong> is the &#8216;un-ordered list tag&#8217; that creates a list with bullets or other images/icons that do not specify or denote an order; hence the term &#8216;un-ordered&#8217;. The other list tag mentioned (<strong>&lt;ol&gt;</strong>) is the &#8216;ordered list tag&#8217; and it creates a list that, instead of bullets, the list elements are marked with numbers or letters. Code examples to follow.</p>
<p>4. <strong>&lt;div&gt;</strong> We all know what the &lt;div&gt; tag is about since we all read the previous article, right? We will use div&#8217;s to create containers for parts of our page. One div will be used to &#8216;hold&#8217; our navigational menu and another div to &#8216;hold&#8217; the main page.</p>
<p>5. <strong>&lt;a href&gt;</strong> The most important tag in HTML: the &#8216;link tag&#8217; or the &#8216;hyperlink tag&#8217;. This makes text &#8216;hyper&#8217; so that when we click on it we can load another page or activate/call some JavaScript (otherwise known as ECMA script).</p>
<p>6. <strong>&lt;img&gt;</strong> This is the &#8216;image tag&#8217;, allows you to link to images so that they show up in our pages. In HTML images are not embedded into the actual page, instead the image tag (<strong>&lt;img&gt;</strong>) only points to where the image is and the browser will attempt to load that image when a surfer loads your HTML page.</p>
<p>That covers the HTML tags we will use in our layout! No need for table tags, <strong>&lt;br&gt;</strong> tags and nasty <strong>&lt;font&gt;</strong> tags.</p>
<h2><strong>THE BASIC PAGE TEMPLATE</strong></h2>
<p>Go to the Web Designers Killer Handbook home page and grab the practice HTML page that we will use as the starting template for this tutorial. You can find it under the heading: &#8216;To create the practice HTML page do the following:&#8217; Follow the instructions there and create your basic HTML page.</p>
<p>Once you have created the template page, create a folder and name it something like: &#8216;myCSSwebsite&#8217; and then drop the HTML page into it. In that same folder, create a new text document and call it: &#8216;myCSS.css&#8217;. Once created open that file and paste in this template CSS code and then save it:</p>
<div>
<p>/* Generic Selectors */</p>
<p>body {</p>
<p>font-family: Georgia, &#8220;Times New Roman&#8221;, Times, serif;</p>
<p>font-size: 14px;</p>
<p>color: #333333;</p>
<p>background-color: #F9F9F9;</p>
<p>}</p>
<p>p {</p>
<p>width: 80%;</p>
<p>}</p>
<p>li {</p>
<p>list-style-type: none;</p>
<p>line-height: 150%;</p>
<p>list-style-image: url(../images/arrowSmall.gif);</p>
<p>}</p>
<p>h1 {</p>
<p>font-family: Georgia, &#8220;Times New Roman&#8221;, Times, serif;</p>
<p>font-size: 18px;</p>
<p>font-weight: bold;</p>
<p>color: #000000;</p>
<p>}</p>
<p>h2 {</p>
<p>font-family: Georgia, &#8220;Times New Roman&#8221;, Times, serif;</p>
<p>font-size: 16px;</p>
<p>font-weight: bold;</p>
<p>color: #000000;</p>
<p>border-bottom: 1px solid #C6EC8C;</p>
<p>}</p>
<p>/**************** Pseudo classes ****************/</p>
<p>a:link {</p>
<p>color: #00CC00;</p>
<p>text-decoration: underline;</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>li :link {</p>
<p>color: #00CC00;</p>
<p>text-decoration: none;</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>a:visited {</p>
<p>color: #00CC00;</p>
<p>text-decoration: underline;</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>li a:visited {</p>
<p>color: #00CC00;</p>
<p>text-decoration: none;</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>a:hover {</p>
<p>color: rgb(0, 96, 255);</p>
<p>padding-bottom: 5px;</p>
<p>font-weight: bold;</p>
<p>text-decoration: underline;</p>
<p>}</p>
<p>li a:hover {</p>
<p>display: block;</p>
<p>color: rgb(0, 96, 255);</p>
<p>padding-bottom: 5px;</p>
<p>font-weight: bold;</p>
<p>border-bottom-width: 1px;</p>
<p>border-bottom-style: solid;</p>
<p>border-bottom-color: #C6EC8C;</p>
<p>}</p>
<p>a:active {</p>
<p>color: rgb(255, 0, 102);</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>/************************* ID&#8217;s *************************/</p>
<p>#navigation {</p>
<p>position: absolute;</p>
<p>width: 210px;</p>
<p>height: 600px;</p>
<p>margin: 0;</p>
<p>margin-top: 50px;</p>
<p>border-right: 1px solid #C6EC8C;</p>
<p>font-weight: normal;</p>
<p>}</p>
<p>#centerDoc {</p>
<p>position: absolute;</p>
<p>padding: 0 0 20px 0; /*top right bottom left*/</p>
<p>margin-top: 50px;</p>
<p>margin-left: 235px;</p>
<p>}</p>
</div>
<p>Don&#8217;t let the CSS freak you out, I will explain the important details and you will soon see how easy it really is. One last thing for you to do before I finish this part of the tutorial, we need to add some code to our HTML page.</p>
<p>In between the &lt;body&gt;&lt;/body&gt; tags you will need to insert this code:</p>
<div>
<p>&lt;div id=&#8221;navigation&#8221;&gt;</p>
<p>&lt;h2&gt;The Main navigation&lt;/h2&gt;</p>
<p>&lt;/div&gt;</p>
<p>&lt;div id=&#8221;centerDoc&#8221;&gt;</p>
<p>&lt;h1&gt;The Main Heading&lt;/h1&gt;</p>
<p>&lt;p&gt;</p>
<p>Go to the Web Designers Killer Handbook home page and grab the practice HTML page that we will used as the starting template for this tutorial. You can find it under the heading: &#8216;To create the practice HTML page do the following:&#8217;.</p>
<p>Follow the instructions there and create your basic HTML page &#8230; and do it now!</p>
<p>&lt;/p&gt;</p>
<p>&lt;/div&gt;</p>
</div>
<p>And in between the &lt;head&gt; &lt;/head&gt; tags you will need to insert this:</p>
<div>
<p>&lt;title&gt;First CSS Tutorial&lt;/title&gt;</p>
<p>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243;&gt;</p>
<p>&lt;link href=&#8221;myCSS.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221;&gt;</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=44&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/11/01/basic-css-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Script Tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/java-script-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/java-script-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:56:30 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[JAVA SCRIPT]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=26</guid>
		<description><![CDATA[Welcome To JavaScript for the Total Non-Programmer This tutorial will take you step by step through the fundamentals of Javascript. You will learn how to write functions, use data from text boxes, create IF-THEN conditionals, program loops, and generally make your web page &#8220;smarter.&#8221; I teach computer classes for a living to corporate clients of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=26&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Welcome To<br />
JavaScript for the Total Non-Programmer</strong></p>
<p>This tutorial will take you step by step through the fundamentals of Javascript. You will learn how to write functions, use data from text boxes, create IF-THEN conditionals, program loops, and generally make your web page &#8220;smarter.&#8221;</p>
<p>I teach computer classes for a living to corporate clients of all levels. After 2 years of teaching, I have learned a lot about communication between people of various levels of computer experience. This tutorial assumes that you have no prior programming experience, but that you have created your own HTML pages.</p>
<p>If you find this tutorial helpful, please let me know (it&#8217;s my only reward).  Also, links are graciously accepted.</p>
<p><strong>What is JavaScript?</strong></p>
<p>Javascript is an easy-to-use programming language that can be embedded in the header of your web pages. It can enhance the dynamics and interactive features of your page by allowing you to perform calculations, check forms, write interactive games, add special effects, customize graphics selections, create security passwords and more.</p>
<p><strong>What&#8217;s the difference between JavaScript and Java?</strong></p>
<p>Actually, the 2 languages have almost nothing in common except for the name. Although Java is technically an interpreted programming language, it is coded in a similar fashion to C++, with separate header and class files, compiled together prior to execution. It is powerful enough to write major applications and insert them in a web page as a special object called an &#8220;applet.&#8221; Java has been generating a lot of excitment because of its unique ability to run the same program on IBM, Mac, and Unix computers. Java is not considered an easy-to-use language for non-programmers.</p>
<p>Javascript is much simpler to use than Java.  With Javascript, if I want check a form for errors, I just type an <a href="NewWindow('IfThen.htm')">if-then</a> statement at the top of my page.  No compiling, no applets, just a simple sequence.</p>
<p><strong>What is Object Oriented Programming?</strong></p>
<p>Everyone that wants to program JavaScript should at least try reading the following section. If you have trouble understanding it, don&#8217;t worry. The best way to learn JavaScript is from the examples presented in this tutorial. After you have been through the lessons, come back to this page and read it again.</p>
<p>OOP is a programming technique (note: not a language structure &#8211; you don&#8217;t even need an object-oriented language to program in an object-oriented fashion) designed to simplify complicated programming concepts. In essence, object-oriented programming revolves around the idea of user- and system-defined chunks of data, and controlled means of accessing and modifying those chunks.</p>
<p>Object-oriented programming consists of Objects, Methods and Properties. An <em><span style="text-decoration:underline;">object</span></em> is basically a black box which stores some information. It may have a way for you to read that information and a way for you to write to, or change, that information. It may also have other less obvious ways of interacting with the information.</p>
<p>Some of the information in the object may actually be directly accessible; other information may require you to use a <em><span style="text-decoration:underline;">method</span></em> to access it &#8211; perhaps because the way the information is stored internally is of no use to you, or because only certain things can be written into that information space and the object needs to check that you&#8217;re not going outside those limits.</p>
<p>The directly accessible bits of information in the object are its <em><span style="text-decoration:underline;">properties</span></em>. The difference between data accessed via properties and data accessed via methods is that with properties, you see exactly what you&#8217;re doing to the object; with methods, unless you created the object yourself, you just see the effects of what you&#8217;re doing.</p>
<p>Other Javascript pages you read will probably refer frequently to objects, events, methods, and properties. This tutorial will teach by example, without focusing too heavily on OOP vocabulary. However, you will need a basic understanding of these terms to use other JavaScript references.</p>
<p><strong>Objects and Properties</strong></p>
<p>Your web page document is an object. Any table, form, button, image, or link on your page is also an object. Each object has certain properties (information about the object). For example, the background color of your document is written <strong>document.bgcolor</strong>.  You would change the color of your page to red by writing the line:  <span style="color:#0000dd;"> document.bgcolor=&#8221;red&#8221;</span></p>
<p>The contents (or value)  of a textbox named &#8220;password&#8221; in a form named &#8220;entryform&#8221; is <strong>document.entryform.password.value</strong>.</p>
<p><strong>Methods</strong></p>
<p>Most objects have a certain collection of things that they can <strong>do</strong>.  Different objects can do different things, just as a door can open and close, while a light can turn on and off.  A new document is opened with the method <strong>document.open()</strong> You can write &#8220;Hello World&#8221; into a document by typing <strong>document.write(&#8220;Hello World&#8221;)</strong> .  <strong>open()</strong> and <strong>write()</strong> are both <em><span style="text-decoration:underline;">methods</span></em> of the object: document.</p>
<p><strong>Events</strong><br />
Events are how we trigger our functions to run.  The easiest example is a button, whose definition includes the words <strong>onClick=&#8221;run_my_function()&#8221;</strong>. The onClick event, as its name implies, will run the function when the user clicks on the button. Other events include OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad, and OnUnload.</p>
<p><strong>Chapter 1, The Message Box</strong></p>
<p>This is a very simple script.  It opens up an alert message box which displays whatever is typed in the form box below.</p>
<p>Type something in the box.  Then click &#8220;Show Me&#8221;</p>
<hr size="3" noshade="noshade" /><strong>HOW IT&#8217;S DONE</strong></p>
<p>Here&#8217;s the entire page, minus my comments.  Take a few minutes to learn as much as you can from this, then I&#8217;ll break it down into smaller pieces.</p>
<p>&lt;HTML&gt;<br />
&lt;HEAD&gt;</p>
<p><span style="color:#22612f;">&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221;&gt;<br />
&lt;!&#8211; Beginning of JavaScript -<br />
</span></p>
<p><span style="color:#990099;">function <span style="color:#0000dd;">MsgBox</span> (textstring) {<br />
alert (textstring) }<br />
</span></p>
<p><span style="color:#22612f;">// &#8211; End of JavaScript &#8211; &#8211;&gt;<br />
&lt;/SCRIPT&gt;<br />
</span></p>
<p>&lt;/HEAD&gt;</p>
<p>&lt;BODY&gt;</p>
<p><span style="color:#22612f;">&lt;FORM&gt;<br />
</span> &lt;INPUT <span style="color:#dd0000;">NAME=&#8221;text1&#8243; TYPE=Text</span>&gt;<br />
&lt;INPUT <span style="color:#dd0000;">NAME=&#8221;submit&#8221; TYPE=Button VALUE=&#8221;Show Me&#8221; onClick=&#8221;<span style="color:#0000dd;">MsgBox</span>(form.text1.value)</span>&#8220;&gt;<br />
<span style="color:#22612f;">&lt;/FORM&gt;<br />
</span></p>
<p>&lt;/BODY&gt;<br />
&lt;/HTML&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=26&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/java-script-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorials for Drupal</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/tutorials-for-drupal/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/tutorials-for-drupal/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:48:29 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[DRUPAL]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=23</guid>
		<description><![CDATA[A. Getting Started There are a number of ways to set up a test environment on your own local computer. Numerous applications and tutorials for a variety of operating systems are located in the Setting up a development environment section of the handbook. Reasons to run a local development server: Developing locally allows you to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=23&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>A. Getting Started</strong><br />
There are a number of ways to set up a test environment on your own local computer.<br />
Numerous applications and tutorials for a variety of operating systems are located in the<br />
Setting up a development environment section of the handbook.<br />
Reasons to run a local development server:<br />
Developing locally allows you to work when not online.<br />
Getting your local server running, even if it is with a simple installation like WAMP,<br />
will help you start thinking in terms of server processes and databases. As you get<br />
deeper into Drupal that knowledge will pay off.<br />
Everything you put on the web is searched, archived and hangs around for a long<br />
time. Do you want your inevitable learning mistakes displayed for the world to see on<br />
Google?<br />
This tutorial uses the example of building a site on a PC with Windows using the<br />
DeveloperSide.net package.<br />
This package has already integrated the following things:<br />
Apache 2.2 HTTP Server<br />
MySQL 5.0 Database<br />
PHP 5.2 and Perl 5.8 Scripting Languages<br />
GUI WAMP-stack Controller<br />
Dynamic DNS Client<br />
Tomcat Servlet/JSP Container<br />
mod_aspdotnet ASP.NET Host Interface<br />
OpenSSL Cryptography Toolkit<br />
mod_security Web Application Firewall<br />
phpMyAdmin MySQL Administration<br />
Joomla<br />
Drupal<br />
WordPress<br />
MediaWiki<br />
phpBB<br />
Do note that any package, like the DeveloperSide one, that includes Drupal for you may<br />
not always have the latest secure version of Drupal. It is, therefore, recommended that you<br />
check the version immediately and upgrade Drupal if needed when using these packages.<br />
I followed their instructions, which built me a working system! For more instructions see<br />
the Web.Developer page in the development environment section. I don&#8217;t remember if it<br />
was automatic or not, but you will find it useful to have the &#8220;Web-Developer Controller&#8221;<br />
icon on your desk top.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
4 of 39 25.10.2008 18:42<br />
The only &#8220;fly in the ointment&#8221; was that when I went to the Drupal web site to start pulling<br />
my modules and themes, there was a big announcement on the front page saying that a<br />
new security release for Drupal 5 had been released and was highly recommended.<br />
I downloaded the latest stable release. I then unzipped it (using WinZip).<br />
Of course, that created a directory called &#8220;Drupal-5.1,&#8221; (the latest version at the time this<br />
was written) but the other software I had installed was looking for a directory called<br />
&#8220;Drupal.&#8221; Well, by getting Apache and its services shut down, I managed to rename the<br />
two directories so that 5.1 was now called &#8220;Drupal.&#8221; It worked! I now had a running 5.1<br />
system!<br />
If you have not set up your site using a package that includes Drupal, it is still very easy to<br />
install in a few minutes. You can find complete instructions in the handbook Getting<br />
Started section under the version number you are installing. Here are the directions for<br />
Drupal 5.<br />
<strong>B. Basic Configuration</strong><br />
Whether you run one site or several, there are some basic things you should do right now.<br />
Here&#8217;s what I do right off the bat; the advantage to doing it in the &#8220;root&#8221; database is that<br />
when I make copies for my other sites this has already been done. I&#8217;d give you a link to<br />
something on the Drupal site, but I never found anything like this.<br />
Go to Administer&gt;&gt;User management&gt;&gt;Roles and create an &#8220;1. administrator&#8221; role.<br />
Go to Administer&gt;&gt;User management&gt;&gt;Users and create a user entry for yourself. This allows you<br />
to test the site by changing your role to meet your needs.<br />
2.<br />
Go to Administer&gt;&gt;User management&gt;&gt;Access control and allow the &#8220;administrator&#8221; role to do<br />
everything.<br />
3.<br />
While you&#8217;re there, go ahead and set what the &#8220;authenticated users&#8221; (logged in) and<br />
&#8220;anonymous user&#8221; (not logged in) can do, such as using your contact form. This is not<br />
engraved in stone; you can change it any time you want.<br />
4.<br />
Go to the Administer&gt;&gt;Site configuration&gt;&gt;Site information page and, near the bottom, set the<br />
&#8220;Default front page&#8221; to &#8220;node.&#8221; As long as you&#8217;re on this page, set basic defaults for<br />
the other fields. I don&#8217;t know about everyone, but I don&#8217;t like, when I visit a site, being<br />
called &#8220;Anonymous&#8221; so I change the designation to &#8220;Visitor.&#8221;<br />
5.<br />
If there are any modules (core or contributed) that you use on all sites, go ahead and<br />
enable them now ((Administer&gt;&gt;Site building&gt;&gt;Modules). For example, you will probably use<br />
&#8220;Page&#8221; on all sites, and maybe &#8220;Story.&#8221; I am finding more and more uses for &#8220;Book.&#8221;<br />
6.<br />
I do recommend turning on (enabling) the &#8220;Path&#8221; core module so you can use<br />
&#8220;normal&#8221; names for your pages.<br />
If you want to use the contact form to email anyone from the site, be sure to enable<br />
the &#8220;Contact&#8221; module.<br />
7. The same goes for themes.<br />
There are a few things I recommend that you do in all your databases, so this is a good<br />
time to do it:<br />
Turn on &#8220;CLEAN URLS&#8221; to make your site more user friendly. Go to Administer&gt;&gt;Site<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
5 of 39 25.10.2008 18:42<br />
configuration&gt;&gt;Clean URLs. At the bottom of the verbiage there is a link to run the &#8220;Clean<br />
URLs Test.&#8221; If it passes, then the &#8220;Enable&#8221; radio button will un-dim. Click on that. (If<br />
the URLs stop working for some reason here are instructions to unset clean URLs.)<br />
In order for me to create any kind of content, I go to Administer&gt;&gt;Site configuration&gt;&gt;Input<br />
formats and set &#8220;Full HTML&#8221; as the default until I get the site ready to go live. Then I<br />
still allow administrators (like my other ID) to use that format. Do this now and you<br />
will avoid a very common problem with building your site.<br />
I don&#8217;t like having &#8220;Promoted to front page&#8221; as a default for content, so I go to<br />
Administer&gt;&gt;Content management&gt;&gt;Content types and turn that off &#8211; in each format.<br />
While you&#8217;re there, decide on your default comment mode. Go to Administer&gt;&gt;Content<br />
management&gt;&gt;Comments&gt;&gt;Settings and set the comments to be entered on a &#8220;separate page&#8221; and<br />
make sure that &#8220;Preview comment&#8221; is set to &#8220;Required.&#8221;<br />
Now, let&#8217;s turn on the Contact form so your users can send you a message. Go to<br />
Administer&gt;&gt;Site building&gt;&gt;Menus and locate the &#8220;Contact&#8221; item. Click on the &#8220;enable&#8221; link.<br />
Remember that later on you will want to go to Administer&gt;&gt;Site building&gt;&gt;Contact form and<br />
finish setting that up.<br />
<strong>C. Creating Multiple Sites On a Local</strong><br />
Computer<br />
Need another test site? Here&#8217;s how to do it the &#8220;easy&#8221; way. [Hint: if creating multiple sites<br />
is desirable make a list of the desired sites before reading through these instructions<br />
completely. Some steps can be done in bulk to save time.]<br />
Why create extra sites? In addition to my having several sites running already, I had some<br />
ideas in the back of my head, not the least of which being a site where I could document<br />
everything I do (like this book). I also had some ideas for other sites that I might put up in<br />
the future. So before you totally pooh-pooh the idea, give it a few minutes&#8217; thought. And<br />
you can always change your mind later; it just might be a bit messier then.<br />
At the very least, I would create a &#8220;working&#8221; site other than my &#8220;root&#8221; site. This makes it<br />
easier to start all over again if you get totally out of control later on.<br />
This may look like a long process, but it&#8217;s deceiving because I spell it out in detail. It is<br />
expanded and updated from the post &#8220;Running multiple sites on a local PC (localhost) from<br />
a single codebase, using Windows.&#8221; For more details on the &#8220;official&#8221; stance on the sites<br />
directories, read Setup of /sites directory for multi-site.<br />
If you want to get deeper into creating multiple sites either locally or on your server, you<br />
can search the forums at drupal.org with the term &#8220;multi-site&#8221;; there is also a group<br />
devoted to this subject at http://groups.drupal.org/multisite. Within the Handbooks, there<br />
is a good section: Multi-site installation and set-up.<br />
Open phpMyAdmin (using &#8220;other&#8221; in Web-Developer Controller)<br />
start bulk loop 1<br />
On the left, select the Drupal51 database. This is the one that was created by the<br />
package installation.<br />
Click on &#8220;Operations&#8221;<br />
Scroll down to &#8220;Copy Database to:&#8221;<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
6 of 39 25.10.2008 18:42<br />
Enter the new database name.<br />
Verify that the radio buttons are clicked for:<br />
Structure and data<br />
CREATE DATABASE before copying<br />
Switch to copied database<br />
Click on the Go button just below this area.<br />
When the copy is complete, click on &#8220;SQL&#8221;.<br />
In the &#8220;Run SQL query/queries on database&#8221; box, enter:<br />
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON<br />
databasename.* TO &#8216;admin&#8217;@'localhost&#8217; IDENTIFIED BY &#8216;superpw&#8217;;<br />
FLUSH PRIVILEGES;<br />
admin is what I call my administrative role (this is the &#8220;super-user&#8221; name);<br />
superpw is the password for this user (I tend to use the same one for all my databases<br />
to make it easy).<br />
Hint: I created and saved this in c:/www/drupal/grant.txt so I could copy and paste.<br />
Change databasename to the new database&#8217;s name.<br />
end bulk loop 1<br />
Close phpMyAdmin.<br />
Go to the www/Drupal/sites directory.<br />
start bulk loop 2<br />
Copy one of the site folders (e.g. default) and name it for your new site.<br />
Open the directory, then open the settings.php file in Notepad.<br />
Change the $db_url and $base_url lines. The $db_url line should have the name of the<br />
database you just created. The $base_url will be how you want to access the site.<br />
Close the file.<br />
If you are going to have site-specific modules or themes, go ahead and create<br />
directories in this site to hold them (named &#8220;modules&#8221; and &#8220;themes&#8221;).<br />
end bulk loop 2<br />
Navigate to the /www/Apache22/conf folder.<br />
Locate and open the &#8220;httpd.conf&#8221; file (Hint: I always make a copy of things I&#8217;m about<br />
to change, just in case I mess up.)<br />
I did notice that my version of Apache sets index.html ahead of index.php, so don&#8217;t have an<br />
index.html in your directory.<br />
Find the line that says &#8220;# Virtual hosts.&#8221; Remove the &#8220;#&#8221; from the next line. This<br />
allows you to make all your other changes in a separate, and less dangerous file.<br />
Save it.<br />
Navigate to the /www/Apache22/conf/extra folder.<br />
Open the httpd-vhosts.conf file.<br />
At the bottom of the existing list, comment out (&#8220;#&#8221;) the examples.<br />
start bulk loop 3<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
7 of 39 25.10.2008 18:42<br />
At the bottom of the existing list, enter:<br />
&lt;VirtualHost *:80&gt;<br />
DocumentRoot /www/drupal/<br />
ServerName databasename<br />
&lt;/VirtualHost&gt;<br />
Change databasename to the new database&#8217;s name.<br />
end bulk loop 3<br />
Close the file.<br />
Navigate to the /windows/system32/drivers/etc folder.<br />
Open the Hosts file with Notepad. Hint: these two steps can be done by using &#8220;other&#8221;<br />
in Web-Developer Controller.<br />
start bulk loop 4<br />
Add a line that says:<br />
127.0.0.1 databasename<br />
Change databasename to the new database&#8217;s name.<br />
end bulk loop 4<br />
Close the file.<br />
Go back to Web-Developer Controller.<br />
Click on Apache2 (top left).<br />
Click the Stop Service button.<br />
Wait for it to change to &#8220;stopped.&#8221;<br />
Click the Start Service button<br />
Wait for it to say &#8220;running.&#8221;<br />
Go for it. You can now start the browser and enter http://databasename.<br />
For more details on directories for multiple sites, see Setup of /sites directory for multi-site.<br />
<strong>D. Error Pages</strong><br />
Occasionally, a user may do something that confuses Drupal, such as typing a wrong page<br />
name or trying to access content they shouldn&#8217;t. These will generate 404 and 403 errors,<br />
respectively.<br />
A recent SEO newsletter, they mentioned the value of letting Drupal handle these errors:<br />
Your unique 404 error page should look like a regular page of your site. It should<br />
include your site&#8217;s header, footer and navigation bar so that the site visitor can<br />
easily click on another area of your site. The content of this unique 404 error<br />
page should contain text explaining that the page selected is no longer available<br />
along with contact information so the site visitor has the option of emailing or<br />
calling your company.<br />
This was one of those &#8220;Duh&#8221; moments for me. How obvious it is that you should make it<br />
easy for the user to get &#8220;back into&#8221; your site.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
8 of 39 25.10.2008 18:42<br />
The same more or less goes for the &#8220;access denied&#8221; (403) error message. Let them know<br />
they did a no-no and try to explain why.<br />
Just go to &#8220;Create content&#8221; and select &#8220;Page.&#8221; I title them &#8220;Access Denied&#8221; and &#8220;Page Not<br />
Found&#8221; but you can call them whatever makes sense to you and your users. When you<br />
submit them, note the node ids. Then go to Administer &gt;&gt; Site Configuration &gt;&gt; Error Handling and<br />
enter &#8220;node/nnn&#8221; in the appropriate boxes.<br />
Page Not Found<br />
Here&#8217;s the HTML for my 404 page:<br />
&lt;p&gt;Sorry! The page you were looking for no longer exists. We redesigned our site and many of the pages have<br />
changed.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;If you are unable to find something on our new site or have a question about our site or services feel free to<br />
&lt;a href=&#8221;/contact&#8221;&gt;contact us&lt;/a&gt;.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;&#8211;Webmistress&lt;/p&gt;<br />
Access Denied<br />
Here&#8217;s the HTML for my 403 page:<br />
&lt;p&gt;We&#8217;re sorry, but you must have permission to view the page you requested.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;If you are already a registered member of this site, please try &lt;a href=&#8221;user&#8221;&gt;logging in&lt;/a&gt;.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;If you are not a member, you need to &lt;a href=&#8221;/join_us&#8221;&gt;join us&lt;/a&gt;.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;If you have any questions about our site or group, please feel free to &lt;a href=&#8221;/contact&#8221;&gt;contact us&lt;/a&gt;.&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;&#8211;Webmistress&lt;/p&gt;<br />
Don&#8217;t worry that you haven&#8217;t created the &#8220;join_us&#8221; page yet. This is an advantage to having<br />
URL Alias support (the Path module) enabled. Just add to your to-do list to create this page<br />
when you get to the &#8220;Creating Content&#8221; step a few chapters later in this book.<br />
E. Accessing Your Test Site(s)<br />
Okay, great, now we have all that software installed. But how do we use it?<br />
First, open the &#8220;Web-Developer Controller&#8221; that you put on the desk top. Look at the top<br />
left. You want to see, and should, if Apache and MySQL are running. If they are, you&#8217;re just<br />
about ready. If not, select Apache, then click on the &#8220;Start Service&#8221; button. Within a few<br />
seconds it should change to &#8220;Running.&#8221; Now select &#8220;MySQL&#8221; and start it.<br />
Fabulous, we have the software ready for us. Now let&#8217;s get us ready.<br />
Fire up your favorite browser. In the Address field type in http://localhost/drupal/ to access<br />
your &#8220;root&#8221; database. Since you&#8217;ve done everything right, you&#8217;re now into your Drupal<br />
database.<br />
<strong>Congratulations! Now the work begins.</strong><br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
9 of 39 25.10.2008 18:42<br />
F. Adding Modules and Themes<br />
Let me first say that a newbie shouldn&#8217;t worry a lot about adding modules and themes at<br />
first. Work on the basics of your site first, then worry about add-ons.<br />
Themes are largely a matter of taste. For example, I have no idea why anyone would use a<br />
&#8220;fixed width&#8221; theme, but lots of people do. One nice thing about themes are they are pretty<br />
much independent of your content (later on you can look at the many submissions that are<br />
dependent on content).<br />
Contributed modules are ways to add or extend functionality of your site. The only module<br />
I, personally, consider necessary is the Nodewords (a.k.a Meta Tags) module; in my<br />
opinion, it should be promoted to &#8220;core&#8221; status. This one allows you to add the &#8220;content,&#8221;<br />
&#8220;keywords,&#8221; and &#8220;robots&#8221; meta tags to your pages. This is useful if you&#8217;re interested in your<br />
search engine rankings. You will also find that many contributed modules also require the<br />
Views module; I go ahead and make that a standard one for my sites.<br />
Now, if you experiment with different themes and modules, as I know you will, despite my<br />
suggestions, you should also look at the Update Status (core in D6) and Site<br />
Documentation modules to make sure you are current and to document and clean up the<br />
mess your experimentation will make. Here are some suggestions on choosing the release:<br />
Strong stomach?<br />
<strong>Installation</strong><br />
Installing a module or theme is pretty much the same until you get to enabling them. Now<br />
keep in mind that I use a Windows based PC (development) and Linux servers (on my live<br />
sites).<br />
Go to the Drupal site and click on the &#8220;Downloads&#8221; tab. Then select either &#8220;Modules&#8221;<br />
or &#8220;Themes&#8221; depending on what you&#8217;re after.<br />
1.<br />
Locate the module 2. or theme you want.<br />
Make sure there is a version for the version of Drupal that you are using. D5 modules<br />
and themes will not work on D6.<br />
3.<br />
I always click on &#8220;Find out more&#8221; and read the stuff again. This gives you the chance<br />
to see if there is support for your release of Drupal. You can also look at pending bugs<br />
and feature requests &#8211; it might change your mind.<br />
4.<br />
5. Download the proper release. (I put them in a Drupal folder in &#8220;My Downloads.&#8221;)<br />
Unzip the downloaded file (I use WinZip). It may tell you that there is only one file in<br />
the zipped file; click &#8220;yes&#8221; or &#8220;OK.&#8221;<br />
6.<br />
Extract the code to to your /sites/sitename/modules or themes folder. If you are not running<br />
multiple sites, this would be /sites/all/modules or themes.<br />
7.<br />
8. That&#8217;s it! Now you need to enable it.<br />
For advanced users<br />
If you have access to a Unix shell (e.g. SSH), the following series of commands will<br />
download and extract the files directly to your server.<br />
Before you start, use the pwd (print working directory) command to confirm that you are in<br />
the correct directory (e.g. modules). If not, use the ls (list directory) and cd (change<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
10 of 39 25.10.2008 18:42<br />
directory) commands to navigate to the correct directory.<br />
Steps:<br />
<strong>Step Download Archive:</strong><br />
wget http://copy_and_paste_archive_url/sitedoc-5.x-1.x-dev.tar.gz<br />
1.<br />
Step Uncompress Archive: tar zxvf sitedoc-2. 5.x-1.x-dev.tar.gz<br />
3. Step Delete/Remove Archive: rm sitedoc-5.x-1.x-dev.tar.gz<br />
Note: the module sitedoc-5.x-1.x-dev.tar.gz is taken here as example please check the current<br />
version and or substitute with your preferred module.<br />
Modules<br />
Modules<br />
You enable a module at Administer&gt;&gt;Site building&gt;&gt;Modules. The non-core modules are listed<br />
farther down. With 5.x, they now show you some of the inter-module dependencies. I turn<br />
them on and &#8220;Save configuration&#8221; in order of the dependencies. For example, &#8220;Views UI&#8221;<br />
requires &#8220;Views&#8221;, so I turn on &#8220;Views&#8221; first, save the configuration, then turn on &#8220;Views<br />
UI.&#8221; and save again.<br />
Most modules introduce some kind of menu items. Those will generally appear<br />
automatically when the modules is enabled. A few menu items will not show up until the<br />
permissions are set (the next step). And even fewer require you to take action to add the<br />
menu items, but the module will have instructions on how to do that.<br />
Ah, now the real work begins. Go to Administer&gt;&gt;User management&gt;&gt;Access control to select who can<br />
use the features of the new module.<br />
If the module introduced new content types, go to Administer&gt;&gt;Content management&gt;&gt;Content types and<br />
configure them. Don&#8217;t forget this may also affect your &#8220;Input formats&#8221; (Administer&gt;&gt;Site<br />
configuration&gt;&gt;Input formats) and &#8220;Categories&#8221; (or taxonomy, Administer&gt;&gt;Content management&gt;&gt;Categories);<br />
you&#8217;ll have to check those too.<br />
Okay, now you can start using the new module.<br />
This Site<br />
My documentation site is a relatively &#8220;vanilla&#8221; implementation of Drupal.<br />
Blog<br />
Book<br />
Comment<br />
Contact<br />
Help<br />
Menu<br />
Path<br />
Codefilter &#8211; Provides tags for automatically escaping and<br />
formatting large pieces of code.<br />
Meta Tags (Nodewords) &#8211; Allows users to add meta tags, eg<br />
keywords or description.<br />
Site Documentation &#8211; Documents and cleans up your<br />
configuration.<br />
To get some idea of what modules are available, check these links: module handbook and<br />
contributed modules handbook.<br />
<strong>Themes</strong><br />
You enable a theme at Administer&gt;&gt;Site building&gt;&gt;Themes<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
11 of 39 25.10.2008 18:42<br />
If it has never been enabled on this site, you will have to check the &#8220;enable&#8221; box and then<br />
click the &#8220;Save configuration&#8221; button at the bottom.<br />
To set up how the theme works, click on the &#8220;Configure&#8221; link (not the tab at the top).<br />
Fill in the fields.<br />
Save the configuration.<br />
Don&#8217;t leave the page yet.<br />
Logo and Favorite Icon<br />
Now use that &#8220;Configure&#8221; tab<br />
I prefer to do this part under the &#8220;Global Settings&#8221; but it can be done theme-by-theme if<br />
you prefer.<br />
The &#8220;Default Logo&#8221; is that little picture (usually) in the upper left corner of the page. For<br />
example, on the &#8220;Bluemarine&#8221; theme, it&#8217;s the Drupal logo.<br />
If you want to change it, here&#8217;s how:<br />
First, find out what size it is because you&#8217;ll want your own logo to be about the same.<br />
(If you are comfortable with HTML and CSS you can also edit the theme&#8217;s code to<br />
accommodate your logo rather than resizing the image. How to edit theme code is not<br />
covered in this beginner&#8217;s guide.)<br />
1.<br />
Bluemarine 48 55<br />
Chameleon 49 57<br />
Garland 64 73<br />
Minelli 64 73<br />
Pushbutton 144 63<br />
Fancy 80 80<br />
Under &#8220;Logo image settings&#8221; either type in the path to your logo, or upload it from<br />
your PC.<br />
2.<br />
Note: Neither one of those options turns off the &#8220;Use default logo&#8221; check box. You<br />
must select the correct check box yourself.<br />
3.<br />
The &#8220;Shortcut icon&#8221; (a.k.a. the favorite icon, or &#8220;favicon.ico&#8221;) is the same way. If you<br />
want to change this, you must specifically say, &#8220;Hey, Drupal, I&#8217;m changing this.&#8221;<br />
4.<br />
Now you click the &#8220;Save configuration&#8221; button. If you did this in &#8220;Global settings&#8221; it affects<br />
all themes (assuming they behave properly); if you did it for a single theme, then only that<br />
theme is changed.<br />
For a list of all available themes, check Themes.<br />
HINT: Going to make a few (or a lot) of changes to a standard theme? Think about copying<br />
it over to your /sites/sitename/themes/ folder and renaming it. Then you can do anything you<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
12 of 39 25.10.2008 18:42<br />
want and still be able to undo it easily by recopying. If the changes ae a bit bigger, think<br />
about contributing it back to the community (with your name, of course).<br />
<strong>G. Creating Content</strong><br />
&#8220;Wow, I&#8217;ve done all this and I still don&#8217;t have any content on my site!&#8221; Well, let&#8217;s fix that.<br />
First, let me explain that the page your visitor sees first upon entering your site is usually<br />
called the &#8220;home&#8221; page. Drupal calls this the &#8220;front&#8221; page, much like a newspaper. This<br />
page is special to Drupal. I know you&#8217;re in a hurry, but read about both &#8220;pages&#8221; and<br />
&#8220;stories&#8221; before you decide which to use to create your front (home) page.<br />
Content Types<br />
Page<br />
Drupal says, &#8220;If you want to add a static page, like a contact page or an about page, use a<br />
page.&#8221; If you&#8217;re used to building web sites with HTML, this is what you&#8217;ve done in the past.<br />
In general a &#8220;page&#8221; is going to stand on its own and will probably have a menu entry. You<br />
may also later add it into a book. When I created my first two sites (based on former static<br />
HTML sites, I made the front page a &#8220;page;&#8221; I have since changed to a &#8220;story.&#8221;<br />
Story<br />
Drupal says, &#8220;Stories are articles in their simplest form: they have a title, a teaser and a<br />
body, but can be extended by other modules. The teaser is part of the body too. Stories<br />
may be used as a personal blog or for news articles.&#8221;<br />
Okay, you&#8217;ve seen the Drupal site and noticed that there are &#8220;pieces&#8221; all over the place.<br />
Look at the front page; you&#8217;ll see several announcements with space between them &#8211; those<br />
are &#8220;stories.&#8221;<br />
I have now switched my sites to use stories on the front page. The &#8220;welcome&#8221; message is<br />
one story. I have an announcement story node that any of my admins can edit. If you want<br />
to have weather or cartoons, a story is a good idea. Another use is if you are on a net ring -<br />
put the ring links into a story.<br />
Book Page<br />
Drupal says, &#8220;A book is a collaborative writing effort: users can collaborate writing the<br />
pages of the book, positioning the pages in the right order, and reviewing or modifying<br />
pages previously written. So when you have some information to share or when you read a<br />
page of the book and you didn&#8217;t like it, or if you think a certain page could have been<br />
written better, you can do something about it.&#8221;<br />
Another way to use a book is to collect related information together. A book has its own<br />
navigation, so it can also be used to de-clutter your menu.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
13 of 39 25.10.2008 18:42<br />
<strong>Blog Entry</strong><br />
You probably already know what a blog is, but just in case: A blog is a diary, collection of<br />
thoughts, or other time-ordered content. The Blog Entry content type is added by the blog<br />
module. The blog module allows you to have a multi-user blog, meaning that every user can<br />
have their own personal blog. This adds titles and breadcrumbs to indicate the blog<br />
authors&#8217; names. Generally if you only have a single blog for a site then it is best to use the<br />
Story node for blog entries.<br />
So have you decided what kind of content you want? No, okay, just start with a page; it&#8217;s<br />
easy. As you go create your content, be thinking about the menu as well.<br />
NOTE: If you want to set your front page (Administer &gt;&gt; Site configuration &gt;&gt; Site<br />
information) as &#8220;node,&#8221; then you need to have at least one piece of content marked as<br />
&#8220;promoted to front page.&#8221; If you don&#8217;t do this, you will keep getting that &#8220;Welcome to your<br />
new Drupal site&#8221; message.<br />
Another Handbook section you may find useful is Creating new content.<br />
Adding Images to your text<br />
There is a choice of facilities for adding images to text items, with pros and cons of each.<br />
1. The Image module, and associated features. Makes each image into a Drupal node,<br />
which ads a lot of capability.<br />
· Image_Attach, which adds a separate image field to the target node, pointing at the<br />
image node. Provides simple image upload, but little other control.<br />
· Image_Assist which embeds the image in a text field. Provides visual image selector,<br />
upload, and control over size and left/right float. Adds necessary HTML to text field.<br />
· drupalimage plug-in to TinyMCE editor which makes Image Assist work with a TinyMCE<br />
field, which displays the result as a WYSIWYG image (though not styled fully according to<br />
your theme).<br />
Also untested further features, including:<br />
· Bulk upload facility<br />
· Interface with the Drupal Gallery support module.<br />
· Similar interface to the Acidfree support module.<br />
2. The CCK ImageField. Very similar to Image Attach, but just uploads image into a<br />
filestore file, and again contains little extra control over e.g. sizes or styles. It is almost<br />
invariably used with Imagecache to give fine control for resizing.<br />
3. IMCE( demo at http://ufku.com/drupal/imce/demo). Provides facilities to upload and<br />
search for images on the server. Functionally similar to the Image_Assist/drupalimage<br />
combination, but the integration with TinyMCE is neater for inserting images, and there is<br />
more control over the attributes of the image once inserted. BUT the image filing and<br />
select window does not look so nice – to the point of affecting usability, and there are bad<br />
things on the Blogs about the associated gallery function.<br />
4. Or go to FCK Editor. From the demo seems as good an editor as TinyMCE, and has its<br />
own image upload and filing mechanism. But:<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
14 of 39 25.10.2008 18:42<br />
· No automatic creation of thumbnails etc. (cf Drupal Image)<br />
· Images are simple separate filestore files – may be a benefit depending on what one<br />
wants?<br />
I have oscillated quite a bit, but (at the moment) am going with the Image module:<br />
· Install the Image module as normal.<br />
· Do the stuff in http://mybesinformatik.com/tinymce-and-drupal5 to add the drupalimage<br />
plugin to TinyMCE.<br />
· Tune the settings in the TinyMCE Profile to show the features required.<br />
· Create a Taxonomy to allow tagging of images for easier retrieval.<br />
Front pages<br />
After following the next few steps, you will be able to easily add / change your front page<br />
anytime in the future.<br />
1. Creating your front page<br />
After logging in as Administrator, select<br />
Create content &gt; Page<br />
from the left menubar, and create your own content that you would like to publish as a<br />
front page. If you are done, hit „Submit” to see the results. Notice that the current URL<br />
(the path to your newly created page) looks like this<br />
http://www.example.com/?q=node/# (normal)<br />
http://www.example.com/node/# (using clean URLs)<br />
where # means a number. We will need that number, so write that down somewhere or just<br />
try to remember that.<br />
<strong>2. Front pages</strong><br />
Now you can either choose to<br />
2.1. Set a single page as your front page or<br />
2.2. Promote your page to the front page, this way adding it to the top of the front<br />
page posts. (Only the first 5-10 lines will be published there (as a preview), you will<br />
have to click on it to see the whole page).<br />
2.3. Use the Front module to fully customize your front pages (theming, different user<br />
roles&#8230;)<br />
2.1. Setting your page as Front page<br />
After creating your custom page, select<br />
Administer &gt; Site Configuration &gt; Site Information<br />
At the bottom of this page where it says „Default front page” you will have something like<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
15 of 39 25.10.2008 18:42<br />
this<br />
http://www.example.com/?q= (normal)<br />
http://www.example.com/ (using clean URLs)<br />
and an input field next to it. That is where you have to enter<br />
node/#<br />
where # is the node number that you previously wrote down. By pressing „Save<br />
configuration” your front page automatically becomes the previously created page. You can<br />
reset that any time you want, by entering only<br />
node<br />
into the input field. (That is the default value).<br />
2.2. Promote your page as Front page<br />
If you want to promote your page to the front page, you should go back to step 1. but now<br />
don&#8217;t press &#8220;Submit&#8221;, or edit your newly created page (navigate to this address)<br />
http://www.example.com/?q=node/#/edit (normal)<br />
http://www.example.com/node/#/edit (using clean URLs)<br />
where # is the node number.<br />
Either way, at the bottom you will find a drop down menu called „Publishing options”,<br />
there you will have to check the „Promoted to front page” checkbox and that’s it. Press<br />
„Submit”.<br />
2.3. Front pages with Front Module<br />
If you really need more control over your front page, you can use the Front module to<br />
Set a different theme 1. to your front page<br />
2. Set different front pages depending on user roles (admin, anonymous, authenticated)<br />
3. Insert custom php snippets into the front page<br />
You can find the Front module at: http://drupal.org/project/front<br />
After installing the Front module, select<br />
Administer &gt; Site configuration &gt; Advanced front page settings<br />
There the drop down menus are pretty self-explaining. If you click on any of the „Front<br />
page for _user role_” you will find<br />
Body: you can input text, html and even php snippets that you want to display<br />
Select Type: you can set other user roles to have the same front page as this, have<br />
default or custom themes be applied to it, etc.<br />
Redirect to: you can set a location where users should be redirected to<br />
If you are satisfied with your settings, press „Save configuration” and you are done.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
16 of 39 25.10.2008 18:42<br />
<strong>G1. Creating a Page</strong><br />
Click on &#8220;Create content&#8221; in the menu, then select what kind.<br />
The title and body are pretty self-explanatory. Below these are a number of collapsible<br />
fields. &#8220;Input format&#8221; controls what you can put into the page; I&#8217;m assuming you are the<br />
&#8220;super-user&#8221; (user/1), so give yourself the priviledge of &#8220;Full HTML.&#8221;<br />
If you have Nodewords installed, the next section is &#8220;Meta Tags.&#8221; It&#8217;s pretty well<br />
documented.<br />
Use the log message to provide information that might be useful to other authors who may<br />
edit your document later, or provide your rationale for making edits to your own or other<br />
people&#8217;s content. The log message is not visible to users without the appropriate content<br />
editing rights.<br />
As logs are recorded on a per-revision basis, each time you revise your content and make a<br />
log, the log message is stored with that particular revision of the article only. If you are<br />
have editing rights over a page you can see a list of revisions (if you selected the option to<br />
make a revision when you edited the document) and their associated log messages by<br />
clicking on the revisions tab.<br />
Hopefully, you already set your default &#8220;Comment settings&#8221; but the front page rarely<br />
deserves comments, so you can disable them.<br />
If you turned on the &#8220;Path&#8221; core module, you&#8217;ll have URL path settings next. You can enter<br />
a &#8220;normal&#8221; name here rather than being required to use &#8220;node/2&#8243; when you refer to it later<br />
on. Hint: if you are converting a site that was static pages, you might want to go ahead<br />
and add &#8220;.htm&#8221; or &#8220;.html&#8221; to the name so that the search engines will continue to find the<br />
page.<br />
&#8220;Menu settings&#8221; is the next section. &#8220;Title&#8221; is what will show in the menu normally.<br />
&#8220;Description&#8221; will show when the user hovers the cursor over the menu item. &#8220;Parent item&#8221;<br />
allows you to create multi-level menus that collapse and expand. &#8220;Weight&#8221; allows you to set<br />
a relative position within the menu; unfortunately, some Drupal core items are hard-coded<br />
at 0.<br />
Chances are you won&#8217;t need &#8220;Authoring information&#8221; unless you want to attribute the page<br />
to someone else. The other use for this section is to control the page or story order when<br />
they are based on the time and date it was created.<br />
Finally, &#8220;Publishing options,&#8221; which you set defaults for earlier, right? You want the page<br />
&#8220;Published&#8221; so it will show up. If this is your &#8220;Welcome&#8221; page, you&#8217;ll want it &#8220;Promoted to<br />
front page.&#8221;<br />
&#8220;Submit&#8221; it.<br />
Congratulations, you now have some content on your site!<br />
<strong>G2. Creating a Story</strong><br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
17 of 39 25.10.2008 18:42<br />
Most of what goes for a page is also true for a story. You can largely consider the two types<br />
to be interchangeable, and it is goodness to have at least two content types because<br />
conflicts can arise in the way content types are used (for example, taxonomy &#8220;collisions&#8221;).<br />
Stories have a &#8220;teaser&#8221; or opening statement intended to grab the reader&#8217;s attention. The<br />
length of the teaser is set in one of two ways:<br />
In Administer&gt;&gt;Content management&gt;&gt;Post settings. The default there is 600 characters. You can<br />
change that.<br />
By specifically identifying a break point with &lt; !&#8211;break&#8211;&gt; [without the space] in your<br />
content (before the default limit).<br />
Note: You may see some places that tell you to use &lt;break&gt; to set a teaser point. This<br />
was originally changed in 5.0 and created a considerable controversy, so it was<br />
backed out.<br />
A story probably shouldn&#8217;t have a menu entry. If you use the general &#8220;convention&#8221; that a<br />
&#8220;page&#8221; is for static or generated content that stands alone, and &#8220;story&#8221; is for collections of<br />
related content (e.g. RSS feeds, newsletter articles, press releases, etc.), then a story is<br />
usually going to be displayed with other stories, so which one would be the menu item?<br />
Generally the menu for a set of stories will be a description of how they are selected for<br />
display.<br />
You may want to promote the story to the front page. For your &#8220;Welcome&#8221; message, you<br />
probably also want to make it &#8220;Sticky at top of lists.&#8221; Unfortunately, there is no core<br />
&#8220;weight&#8221; feature, so you have to play with the dates and times in the &#8220;Authoring&#8221; section to<br />
control the order. (Or you can use the Weight module.)<br />
<strong>What&#8217;s a Teaser?</strong><br />
This is from a post by zoon_unit on January 10, 2007.<br />
A &#8220;teaser&#8221; is essentially a snippet of text designed to tell the user the content of a post<br />
without reading the entire post. Since most writers have embraced the common<br />
journalistic style of explaining the nature of an article in the first paragraph, teasers work<br />
well for most articles.<br />
Here&#8217;s what happens:<br />
A node contains 1. an entire article.<br />
Drupal&#8217;s &#8220;teaser&#8221; function, &#8220;node_teaser,&#8221; strips the first x number of characters from<br />
the article and makes it available as content. The exact length is determined by the<br />
value set in Drupal&#8217;s Administer » Content management &gt;&gt; Post settings.<br />
2.<br />
So, you list a bunch of articles on a page. You want the articles to display only a<br />
snippet of text from the full article, so that you can fit a bunch of articles on a page<br />
without requiring the user to page down through tons of text. If the user likes the<br />
&#8220;teaser&#8221; content of the article, they will click on the article&#8217;s title and see the full<br />
content of the article on its own page. In a sense, teasers function like summaries of<br />
an article, except that the software decides where to cut off the text. If you want to<br />
determine where a teaser article ends, you can insert the comment tag to instruct<br />
Drupal exactly where to fashion the break between full text and teaser text.<br />
3.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
18 of 39 25.10.2008 18:42<br />
G3. Creating a Book Page<br />
Generally, I only create one book page for each book. This is the first one, usually the<br />
introduction. All other pages will be added as &#8220;Child pages&#8221; (to be accurate, child pages<br />
will still have the &#8220;book page&#8221; content type set for them).<br />
In addition to the things I said about pages, a book page has a &#8220;Parent.&#8221; For the first page,<br />
this will be &#8220;&lt;top-level&gt;.&#8221; If you use &#8220;Add child page&#8221; the &#8220;Parent.&#8221; selection should be<br />
already filled in with the book&#8217;s name. If you create another book page, you would need to<br />
make sure you properly select which book or page the new one is to be made a child of.<br />
The top page of the book probably deserves a menu entry. The rest do not, unless they are<br />
really special. Remember, a book has its own navigation.<br />
You are currently reading a &#8220;book.&#8221;<br />
G4. Creating a Blog entry<br />
Blog entries are a little different. Assuming you enabled the &#8220;Blog&#8221; module, you should see<br />
a &#8220;My blog&#8221; entry in your navigation menu. When you click on that, there will be a &#8220;Post<br />
new blog entry&#8221; link on that page.<br />
If the blog is a diary, you probably want to use the date for the title.<br />
If it&#8217;s a collection of thought, give it a meaningful title.<br />
Type in the content of the entry.<br />
Your blog will always show the most recent entries on the beginning page when visitors<br />
view it.<br />
H. Custom Blocks<br />
Following is a simple example of custom block. For more information on blocks in general,<br />
see the Blocks page of the handbook.<br />
Adding A &#8216;Contact Information&#8217; Block<br />
A business or support group should always let people know how to contact them. One easy<br />
thing is to include your mailing address on your pages. This is about the easiest kind of<br />
block to start with.<br />
Go to Administer&gt;&gt;Site building&gt;&gt;Blocks. It should already be sitting on your<br />
default theme, but if not, select the right one.<br />
1.<br />
Click on the 2. &#8220;Add block&#8221; tab.<br />
3. Fill in the &#8220;Description&#8221; and &#8220;Body.&#8221; Here&#8217;s a sample body:<br />
Example Organization&lt;br&gt;<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
19 of 39 25.10.2008 18:42<br />
123 Main St.&lt;br&gt;<br />
Mytown, State Zip&lt;br&gt;<br />
USA&lt;br&gt;<br />
(123) 456-7890<br />
4. Save the block.<br />
5. Now you can &#8220;Configure&#8221; the block to add the block&#8217;s title and define it&#8217;s &#8220;Visibility&#8221;.<br />
Follow the Configure link next to the block and enter &#8220;Contact Information&#8221; as the<br />
Block&#8217;s title.<br />
6.<br />
Decide if you want to allow users to turn the block on or off, and, if so, which roles<br />
should have that ability. You can leave this with no changes to allow everyone to see<br />
it. Then choose which pages it will be shown on; Leave this empty to show the block<br />
on all pages.<br />
7.<br />
8. Save the block.<br />
Now you&#8217;re back on the block list. Find the block you just created in the list and<br />
choose a &#8220;Region&#8221;. You can use the &#8220;Weight&#8221; parameter to set its position with in the<br />
selected area; again, I like the address at the bottom, so I use a heavier weight.<br />
9.<br />
10. Click on the &#8220;Save blocks&#8221; button.<br />
Adding a Last Updated Statement<br />
It is fairly common practice, especially on a group site to let the visitors know when the<br />
site was last updated. This example requires you, the webmaster or administrator<br />
(sometimes called the &#8220;super user&#8221;) to maintain the block. There are ways to automate this,<br />
but for right now, we&#8217;ll do this manually.<br />
Follow the same process as for the &#8216;Contact Information&#8217; block, giving this one a<br />
slightly heavier weight to sink it to the bottom.<br />
&lt;em&gt;Site Late Updated on Feb. 12, 2007&lt;/em&gt;<br />
For this block, lets set it to show on every page except the home (front) page. So<br />
under &#8220;Page specific visibility settings,&#8221; I clicked on the &#8220;Show on every page except<br />
the listed pages.&#8221; radio button, and entered &lt;front&gt; in the pages box.<br />
Creating a Newest Posts Block<br />
Creating a newest posts block is easy using Views. With slight modification you can use<br />
this to list comments or list nodes by score if you have a rating module installed. The<br />
information below is for version 5.X of Drupal. Things may be different in Drupal 6.X<br />
Step 1 &#8211; Installing Views<br />
Download install the Views Module. Follow the instruction that come with it.<br />
Step 2 &#8211; Block Title<br />
Determine what to call this block.<br />
Step 3 &#8211; Number of Posts<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
20 of 39 25.10.2008 18:42<br />
Determine how many posts you want in the block. You might also want to decide what<br />
information you want to be displayed. For this tutorial we are going to display titles, but<br />
you could display the teaser as well. The amount of information that is displayed could<br />
affect your choice as to the number of posts to display.<br />
Step 4 &#8211; Starting Views<br />
Login to the admin page of your Drupal site and go to Site Building &gt; Views.<br />
Step 5 &#8211; Block Basic Information<br />
Once you are on the Administer Views page, click on add. Fill in the basic information -<br />
Name, Description, and Access Privileges. The name must be alphanumeric and you must<br />
use underscores for spaces.<br />
Step 6 &#8211; Basic Block Setting<br />
Creating the block is very easy. Move down the page until you see word &#8220;Block&#8221; as a<br />
hyperlink. Clicking on it will expand the block section.<br />
Click on the check-box &#8220;Provide Block&#8221;. This means that Views will provide a block for you.<br />
You will find it in the top of the block section.<br />
Now we want to tell it how to display the output. You have several options but for this the<br />
best is &#8220;list View&#8221;. Since we are just going to list the titles. If you wanted more information,<br />
you could use the &#8220;Teaser List&#8221; to provide the name and description of the post. So, where<br />
it says &#8220;List Type&#8221; you will select &#8220;List View&#8221;<br />
Finally, you need to tell how many nodes you want in the list. Just fill in &#8220;Nodes per Block&#8221;<br />
with the number that you want. If you are using a theme like &#8220;Denver&#8221;, you might want to<br />
use 5 for the top regions. If you are placing in a side bat you could use 10 or more.<br />
Depends on how fast your content changes.<br />
Step 7 &#8211; Selecting Fields<br />
After that is finished, you want to tell views what field you want to display. The next<br />
section below &#8220;Block&#8221; is the &#8220;Fields&#8221; section. Click on &#8220;Fields&#8221; to open it. Then select the<br />
field that you want. Then click on the &#8220;Add Field&#8221; button. For this example, we want to<br />
select the title of the node. So you want to look for &#8220;Node : Title&#8221;. If you wish you can give<br />
it a label like &#8220;Newest Posts&#8221; or &#8220;Latest News&#8221;.<br />
Step 8 &#8211; Filtering<br />
You may not want every thing showing in your latest posts. You can limit it. For that you<br />
have to go down the page to &#8220;Filters&#8221;. Click on it to reveal the filtering options. This is<br />
where you can select the content type(s) to show in the block. Where it says &#8220;Add Filer&#8221;<br />
select &#8220;Node : Type&#8221; and then click on the &#8220;Add Filter&#8221; button. For the operator you want<br />
to select &#8220;Is One Of&#8221;. Then you pick the content type from the &#8220;Value&#8221; drop down list.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
21 of 39 25.10.2008 18:42<br />
Step 9 &#8211; Saving View<br />
Once you are all done on this page, save your view.<br />
Step 10 &#8211; Displaying the Block<br />
Go to Site Building &gt; Blocks. Here you will see all the blocks. Find your newly created one<br />
and decide what region to place it. Depending on your theme, you may have a lot of<br />
regions or very few few regions.<br />
Once it is assigned to a region, set the weight. The larger the weight value, the farther<br />
down the block will be on the page.<br />
Once the weight is set, configure the block. This will allow you to decide who see the block<br />
and on what pages it shows on. A good place to place a listing of newest posts is on the<br />
front page. To do that, you want to find &#8220;Pages&#8221; and put in the text area. Then right above<br />
select the &#8220;Show only on selected pages&#8221; option.<br />
Once you are done making all your setting for this block, save this block.<br />
<strong>Notes</strong><br />
You can use this method to show your content in other ways. You could show the highest<br />
rated content or most recent comments.<br />
You may want to have a special page for listing your 25 highest rated or 25 newest posts.<br />
There are special modules that allow you to do this. You can use &#8220;Insert View&#8221; or<br />
&#8220;Viewfield&#8221; to put views in pages.<br />
Check out the modules for Views at http://drupal.org/project/Modules/category/89<br />
I. Working with the Menu<br />
Introduction<br />
This will not be an exhaustive piece on the subject of menus. My main point will be to start<br />
you on building your menu and giving you a flavor for how it works. A more complete guide<br />
to menus can be found at Creating a menu structure.<br />
As we all know the menu, or navigation system, can make or break a web site. It must be<br />
easy to follow, often referred to as &#8220;intuitive.&#8221; It must be complete, yet compact.<br />
There is a lot of content on the Drupal site on menus. Most newbies have trouble<br />
understanding it all. I&#8217;ve been using Drupal for just over a month as I write this and I still<br />
have a long way to go on completely understanding menus.<br />
For beginners it can be very confusing to understand the difference between menus and<br />
categories. The menu is a navigation system and categories is a system to order content<br />
data. So menus is to arrive at content and categories to order it. Initially to understand<br />
Drupal well, you have to see these as two separate things.<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
22 of 39 25.10.2008 18:42<br />
With a menu you can point directly to a node, like a page or a story, but you can also point<br />
to a term in a category, which would show you a summary list of stories or pages.<br />
How To Menu<br />
Drupal offers three primary ways, which may be combined, to provide your users with site<br />
navigation.<br />
Textual menu &#8211; this is the &#8220;standard&#8221; line-by-line type of menu, like what you see on<br />
most sites, including mine. It can be enhanced in a few ways, such as using a CSS or<br />
separate book navigation (as I have done here).<br />
1.<br />
Tabbed menu &#8211; becoming more popular because it&#8217;s a little more &#8220;gee-whiz&#8221; in its<br />
presentation. It is debatable as to whether it is any more effective for your visitors. In<br />
Drupal, it is divided into &#8220;Primary&#8221; (the tabs you always see) and &#8220;Secondary&#8221; (the<br />
part that drops down, or slides out). Not all themes support secondary links.<br />
2.<br />
Books &#8211; Books are organized separately from menus, but have their own navigation,<br />
which you can see on this site. See my section Creating a Book Page.<br />
3.<br />
Textual Menu<br />
The textual navigation is the easiest to understand. As a matter of fact, I still don&#8217;t<br />
understand how to make the &#8220;secondary&#8221; part of tabbed navigation work the way a lot of<br />
people think it should (drop down).<br />
You may see the terms &#8220;primary links&#8221; and &#8220;secondary links&#8221; in many posts. This is one<br />
area where I find the Drupal documentation confusing (at best). While they sounded great,<br />
and I am now using them, they may not be the best thing for someone just starting out.<br />
Stick to the standard &#8220;Navigation&#8221; menu until you have a better feel; you can always go<br />
back and change this later.<br />
For the most part, the &#8220;standard&#8221; menu is best built as you create content, but may require<br />
a little tweaking as you see how it lays out.<br />
When you create a page, story, blog, or book page, one of the fields that you may (should)<br />
fill in before submitting, is the menu entry (if the node is to have one). You have the &#8220;title&#8221;<br />
(what is to appear in the menu as people see it) and a &#8220;description&#8221; (what they will see if<br />
they hover the cursor over that entry).<br />
I rarely worry about the &#8220;weight&#8221; until I see how it shows up in the menu. At that point,<br />
you can either go back and edit the content you created or go to Administer &gt;&gt; Site building &gt;&gt;<br />
Menus and edit it there.<br />
Okay, that was the easy part. Now let&#8217;s say you want this particular content listed in the<br />
menu as a<br />
child of some other page. No problem! Let&#8217;s say you have a subject&#8217;s introductory page<br />
already listed in the menu, for example &#8220;Family History.&#8221; The page you&#8217;re creating is<br />
&#8220;1860-1899.&#8221; When you build the menu entry, you&#8217;ll notice a selection box labeled &#8220;Parent<br />
Item.&#8221; Scroll down the list until you find &#8220;Family History.&#8221; Now when you submit this page,<br />
it will be a child of &#8220;Family History,&#8221; making that item an expandable menu item. You just<br />
created a hierarchical menu!<br />
Tabbed Menu<br />
The Drupal Cookbook (for beginners) http://drupal.org/book/export/html/120612<br />
23 of 39 25.10.2008 18:42<br />
In those themes that support this technique, the &#8220;Primary&#8221; seems to get built automatically<br />
as you build the &#8220;Navigation&#8221; menu, unless you specify a different menu set. I have no idea<br />
yet how to make drop down &#8220;secondary&#8221; links part work &#8211; I think it requires a separate<br />
module. I do know how to make the secondary links appear in a block, if they exist. I like<br />
the way that works, but it may not be for everyone.<br />
Books<br />
The book &#8220;menu&#8221; is built automatically for you. The only thing you have to worry about is<br />
the order of the entries (hint: weight).<br />
The only &#8220;complicated&#8221; part is turning on the book navigation block, which is done at<br />
Administer &gt;&gt; Site building &gt;&gt; Blocks. All you really need to do is to tell Drupal which region to<br />
place it in and its relative weight. You can get fancy, if you want, with your style sheets.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=23&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/tutorials-for-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Basic Tutorials For AJAX</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/basic-tutorials-for-ajax/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/basic-tutorials-for-ajax/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:39:46 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=21</guid>
		<description><![CDATA[JavaScript has had the XMLHttpRequest object for a good number of years now, but it&#8217;s really only started getting wide attention recently. All this attention is mostly due to some showoff web applications that make every developer who sees them think, &#8220;I want my site to do that!&#8221; But it also has to do with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=21&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>JavaScript has had the XMLHttpRequest object for a good number of years now, but it&#8217;s really only started getting wide attention recently. All this attention is mostly due to some showoff web applications that make every developer who sees them think, &#8220;I want my site to do that!&#8221; But it also has to do with the spiffy, spiffy name given to it by the folks at AdaptivePath, who named this asynchronized application <a title="http://www.adaptivepath.com/publications/essays/archives/000385.php" rel="nofollow" href="http://www.adaptivepath.com/publications/essays/archives/000385.php">Ajax</a>. Maybe you&#8217;ve heard of it?</p>
<p>A few high-profile Google applications in particular made a splash with Ajax:<a title="http://www.google.com/webhp?complete=1" rel="nofollow" href="http://www.google.com/webhp?complete=1">Suggest</a>, and <a title="http://maps.google.com/" rel="nofollow" href="http://maps.google.com/">Maps</a>, and <a title="http://gmail.google.com/gmail" rel="nofollow" href="http://gmail.google.com/gmail">Gmail</a>. It&#8217;s also powers some of the core functionality in the user interface of the ever-so-popular photo sharing site <a title="http://www.flickr.com" rel="nofollow" href="http://www.flickr.com/">Flickr</a>. By now, Ajax has become a buzzword, and may even be the first JavaScript object with its own <a title="http://www.ajaxian.com/" rel="nofollow" href="http://www.ajaxian.com/">fan website</a>. Date.com doesn&#8217;t count, although I did have a scintillating chat with a lady there once about the getTimeZoneoffset method.</p>
<p><a name="What_is_Ajax.3F"></a></p>
<h3>What is Ajax?</h3>
<p>So what is this fancy object that everybody wants a piece of? In brief, it&#8217;s a solution to one of the big annoyances of web interfaces. Generally, the user inputs some data or makes a choice, and clicks a button that sends the data to the server. The server takes a look at the data and sends back a whole new web page, which is loaded into the browser. Reloading a page every time you want to do something is annoying, disjunctive and time-consuming for the user. XMLHttpRequest moves that browser-server interaction to behind the scenes, so the user can just keep on playing with the same page, even while elements on the page are talking to the server! Go take a look at <a title="http://www.google.com/webhp?complete=1" rel="nofollow" href="http://www.google.com/webhp?complete=1">Google Suggest</a> if I&#8217;ve lost you &#8212; it&#8217;s a nice, eloquent example of this.</p>
<p>JavaScript has always been able to sneakily trigger a server-side script without anything happening in the browser by using a few classic tricks. This one, for example:<tt>onSubmit='runascript = new Image(); runascript.src="<a title="http://www.wired.com/images/archiveyscript.php" rel="nofollow" href="http://www.wired.com/images/archiveyscript.php">http://www.wired.com/images/archiveyscript.php</a>?" + this.value'</tt>. That sort of chicanery is good, maybe, for caching form data to a file on the server, but it doesn&#8217;t return any information to the JavaScript that calls it, so its usefulness is limited. Ajax, on the other hand, can get a full parcel of data back from the script it calls. Hence the &#8220;XML&#8221; part of the name &#8211; which really is just there for looks, kind of like the &#8220;Java&#8221; part of JavaScript, because the returned data can be plain text or whatever you like, if XML is overkill or just not your cup of tea.</p>
<p>This opens up millions of exciting possibilities. Every form submission, every JavaScript event, and heaven knows what else, can now interact with server-side databases and processing power. Data retrieval, password authentication, image generation &#8211; you name it, Ajax can trigger it.</p>
<p><a name="Making_Your_Own"></a></p>
<h3>Making Your Own</h3>
<p>The potential of Ajax-enhanced web apps is limited only by your imagination &#8211; and by browser support. Mozilla-based browsers can do it, and Safari, and newer versions of Explorer, and Opera 8 but not Opera 7. It&#8217;s best to incorporate a fallback way of doing things for users who aren&#8217;t as cutting edge as you&#8217;d like them to be. Also, Explorer does things somewhat differently (of course) from all the other browsers, so it&#8217;s necessary to fork the code to account for the irritating little 80-odd percent of the population who use IE.</p>
<p>Let&#8217;s build a simple application that accepts input from the user, passes it to some PHP on the server that checks it against a database, and returns the result to the browser. It comes in three parts. First, we need an HTML form. This you&#8217;ve seen before:</p>
<pre>&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;Report&lt;/title&gt;
 &lt;script type='text/javascript' src='xhr.js'&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="fallbackpage.php" method="post"&gt;
 &lt;p&gt;Welcome, student. Please enter your essay here:&lt;textarea name="essay" id="essay"&gt;
 &lt;/textarea&gt; &lt;input type="submit" name="submit" value="Submit" onClick="return
 grade(this.form.essay.value);"&gt;
 &lt;/p&gt;
 &lt;/form&gt;
 &lt;/body&gt;
 &lt;/html&gt;
</pre>
<p>Note that, for users without support for our script (named xhr.js), the form will just submit to the fallback page at fallbackpage.php.</p>
<p>Next comes the JavaScript. This is the exciting part, so we&#8217;ll take it slow.</p>
<pre> function grade(essay) {
</pre>
<p>First, we initialize the object. We have to do it two ways, for different browsers.</p>
<pre>    // Mozilla version
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    // IE version
    else if (window.ActiveXObject) {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
</pre>
<p>Then, we escape the user input to make it URL-safe:</p>
<pre>    essay=encodeURIComponent(essay);
</pre>
<p>and use the <tt>open</tt> method of the object to open a connection to the PHP script:</p>
<pre>    xhr.open("POST","grade.php");
</pre>
<p>The method requires two arguments:first, the HTTP method (GET or POST); second, the URL of the script.</p>
<p>A quick HTTP header prepares the script for what it&#8217;s getting, and then the <tt>send</tt> method transmits the actual request:</p>
<pre> xhr.setRequestHeader(
      'Content-Type',
      'application/x-www-form-urlencoded; charset=UTF-8'); xhr.send(essay);</pre>
<p>This last step isn&#8217;t necessary for GET requests, wherein all the data can be contained in the query string of the URL.</p>
<p><a name="Getting_Results"></a></p>
<h3>Getting Results</h3>
<p>Now we&#8217;re ready to see if the HTTP request worked. The <tt>readyState</tt> property counts up from zero during the request, and shows 4 when the server page has loaded successfully.</p>
<pre> xhr.onreadystatechange=function() {
      if (xhr.readyState==4) {
</pre>
<p>If the request worked, then we can get the output of the server-side script by querying the <tt>responseText</tt> property, which contains a string. For more complex server script output, a <tt>responseXML</tt> property, which can hold a full document object of XML data, is also available.</p>
<pre>      grade = xhr.responseText;
      alert ("Nice essay. Your grade is " + grade);
    }
    return false;
 }
</pre>
<p>Want to see all that in a pastable block? Here it is in a <a title="http://www.wired.com/wired/webmonkey/stuff/Ajax_for_Beginners_code1.html" rel="nofollow" href="http://www.wired.com/wired/webmonkey/stuff/Ajax_for_Beginners_code1.html">separate file</a>.</p>
<p>Finally, the third component is the PHP script, which lives on the server and waits patiently for the JavaScript to pass it some juicy data. This example uses PHP, but any language you like &#8212; Ruby, Perl, C, ASP &#8212; can do as well. The core of this example script is a natural-language function called <tt>grade_essay()</tt> that grades student essays from 1 to 100, but I will redact that part to conserve space.</p>
<pre> &lt;?php
 function grade_essay($essay) {
      return strlen($essay);
 }
 $essay = urldecode(implode(file('php://input')));
 $grade = grade_essay($essay);
 echo $grade;
 ?&gt;
</pre>
<p>The <tt>php://input</tt> grabs the POST data, which gets put into a string, decoded and passed to the ingenious grading algorithm. The algorithm returns a numeric grade. Lastly, we just output the grade with <tt>echo</tt> &#8211; ordinarily, this would display in the browser, but since the PHP script is running &#8220;behind the scenes,&#8221; the string output is simply returned to the JavaScript that called it. If you need structured data, an XML document would be output with an <tt>echo</tt> statement in just the same way, but the content-type of the output page must be set to <tt>text/xml</tt>.</p>
<p>What the user sees is this:She types her essay into the text area in the browser, clicks Submit, and within instants an alert box pops up giving her a final grade on the essay. Invisibly, the essay has been sent to the server, read and evaluated by a team of PHP gnomes, and returned with a grade, without ever reloading the page. The user can modify her essay and resubmit it endlessly.</p>
<p>And that&#8217;s the gist of the almost magical XMLHttpRequest object! The example is simple, but the uses of the object can be elaborately, multifariously clever. If you need further inspiration and edification, a burgeoning number of examples are dotted around the Web:</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=21&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/basic-tutorials-for-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Mysql Tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/mysql-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/mysql-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:32:33 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=19</guid>
		<description><![CDATA[Overview MySQL is the world&#8217;s most popular open source, binary database server. It is capable of supporting over 50,000,000 records. SQL (Structured Query Language) is the language used to to communicate with the MySQL server. With the aid of this tutorial, you will learn how to build a RDBMS (Relational DataBase Management System). Table Joins, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=19&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Overview</h4>
<p>MySQL is the world&#8217;s most popular open source, binary database server. It is capable of supporting over 50,000,000 records. SQL (Structured Query Language) is the language used to to communicate with the MySQL server. With the aid of this tutorial, you will learn how to build a RDBMS (Relational DataBase Management System). Table Joins, are the key to building efficient databases and harnessing the essential power of MySQL. Without table joins, a complex relational database will be as slow as a standard flat file database. PerlScripts JavaScripts.com will teach you how to utilise table joins and greatly increase the speed of your database queries. PerlScripts JavaScripts.com has taught lead programmers of other programming firms how to utilize the true power of MySQL.</p>
<h4>What you need</h4>
<p>You will need a web host that offers access to a MySQL server. Most hosts offer some sort of control panel, allowing you to set up and create your databases. If you need MySQL hosting, we have MySQL enabled plans from as little as $13.70. Once you have a host, you will need to ask them for certain information or use your control panel to create a database. Our Basic hosting plan ($13.70/mo) allows you to create up to 3 databases. The information you need is :</p>
<h4>Path to the server</h4>
<p>Database name</p>
<p>Username</p>
<p>Password</p>
<h4>Connecting to the DB Server</h4>
<p>Connecting to the database is easy. First you must load the MySQL module. Near the top of your script add this code :</p>
<p>use Mysql;</p>
<p>The line above will load the module ( or class of predefined subroutines ) named Mysql.pm into your script. To make database connections quick and easy, place your login details into a set of variables. These variables will be passed as arguments to the connect subroutine and should be declared near the top of your script or before using the connect command.</p>
<p>$DBHOST = &#8220;localhost&#8221;;<br />
$DBNAME = &#8220;mydatabase&#8221;;<br />
$DBUSER = &#8220;perlscripts&#8221;;<br />
$DBPASS = &#8220;ywe6ywnq&#8221;;</p>
<p>You now need to begin constructing what is known as an object. Below is an example of how to utilize the connect subroutine.</p>
<p>$DB = Mysql-&gt;connect($DBHOST, $DBNAME, $DBUSER, $DBPASS);</p>
<p>Once the above code is executed, assuming the login details are correct, you are connected to the MySQL server. For demonstration purposes only, the code below could be used to select and print the first 100 records from a table named &#8220;employees&#8221;.</p>
<p>$DB  = Mysql-&gt;connect($DBHOST, $DBNAME, $DBUSER, $DBPASS);<br />
$qry = qq~SELECT * FROM employees WHERE id &lt; 100~; while( @emps = $qry-&gt;fetchrow) {<br />
print qq~<br />
$emps[0], $emps[1], $emps[2]</p>
<p>~;<br />
}</p>
<p>The code above, when translated into English, says &#8220;Connect to the server, select all columns from the table named employees where id is less than 100, then while the data is placed into an array called emps using the fetchrow method, print columns 1, 2 and 3 then a line break.&#8221;</p>
<h4>Basic Queries</h4>
<p>Some of the more popular queries are the easiest to execute, but can also be the most dangerous. For example, to delete a record, you might use :</p>
<p>DELETE FROM employees WHERE age &gt; 35</p>
<p>However, if you forgot to enter a WHERE clause and condition, you would delete the entire table.</p>
<h4>Advanced Queries</h4>
<p>Advanced queries should be used in preference to extracting data then formatting it using another language. Many programmers either do not have the knowledge or just do not understand the power and speed of MySQL. The MySQL server is all about speed and efficiency. Manipulate and format the data as much as possible using MySQL before passing it on to Perl or PHP. Use built in functions and nested functions to achieve your desired result. In most cases, you will be able to extract all necessary records from all tables in one call to the database.</p>
<h4>Table Joins</h4>
<p>Table Joins are by far the most useful function on large and complex databases. They allow you to select and retrieve records from multiple tables in one action. When selecting records from multiple tables, you must use a common denominator other wise many more records than you expected will be returned. There must a column name common to two or more tables. Let&#8217;s assume we have two tables with the following structure :</p>
<p>Table 1</p>
<p>employees</p>
<p>Columns</p>
<p>id<br />
firstname<br />
lastname<br />
address</p>
<p>Table 2</p>
<p>salary</p>
<p>Columns</p>
<p>id<br />
hourly<br />
ssn</p>
<p>Note that the common column is the id column. Your where clause must contain a common column, otherwise more records than you expect will be returned. In the following select statement, each table is separated by a comma. We are selecting all columns (denoted by an asterisk *) where the id is identical in both tables.</p>
<p>SELECT * FROM employees, salary WHERE employees.id = salary.id &amp;&amp;<br />
employees.firstname = &#8216;Grayson&#8217;</p>
<p>In the example above, column names are preceded by table names to avoid confusion. Strings (as opposed to integers) must be quoted. The id is an integer (a whole number) so it does not need to be quoted. The first name is a string, so it must be quoted. Note that the common column is the id. Without the id check (employees.id = salary.id), all records from both tables that contain the string &#8216;Grayson&#8217; would be returned.</p>
<h4>MySQL Tips and Functions</h4>
<p>• Comparison operators<br />
= 	Equals<br />
&lt; 	Less than<br />
&lt;= 	Less than or equal to &gt; 	Greater than<br />
&gt;= 	Greater than or equal to<br />
&lt;&gt; 	Not equal to<br />
!= 	Not equal to<br />
LIKE 	Compare strings</p>
<p>• Mathematical operators<br />
( ) 	Use parentheses to force precedence<br />
+ 	add<br />
- 	subtract<br />
* 	multiply<br />
/ 	divide<br />
% 	modulo</p>
<p>• Conditional operators<br />
|| 	Logical &#8220;or&#8221;<br />
| 	Bitwise &#8220;or&#8221;<br />
OR 	Same as Logical &#8220;or&#8221;<br />
&amp;&amp; 	Logical &#8220;and&#8221;<br />
&amp; 	Bitwise &#8220;and&#8221;<br />
AND 	Same as Logical &#8220;and&#8221;</p>
<h4>• Some Common Functions</h4>
<p>CONCAT(str1,str2) 	Concatenates strings<br />
DAYNAME(date) 	Returns the dayname for the given date<br />
LAST_INSERT_ID( ) 	Returns the last record ID inserted<br />
LENGTH(column) 	Returns the length of a string in characters<br />
TRUNCATE(n,n) 	Returns stated number of decimal places<br />
UNIX_TIMESTAMP( )   	Returns the epoch</p>
<p>• Some Aggregate Functions<br />
AVG(column) 	Average number from returned results<br />
MAX(column) 	Returns the largest number from returned results<br />
MIN(column) 	Returns the smallest number from returned results<br />
SUM(column) 	Returns the sum of all returned results</p>
<p>Note : not all databases servers support all functions, many depend on the version your server is running. There are hundreds of functions that can be used alone or nested within one another. You really should buy a book for a complete reference.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=19&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/mysql-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Basic Oscommerce Tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/basic-oscommerce-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/basic-oscommerce-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:00:14 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[OSCOMMERCE]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[MAGENTO]]></category>
		<category><![CDATA[MAMBO]]></category>
		<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=10</guid>
		<description><![CDATA[1. Initial setup of your Store &#8211; Configuration The whole admin section of osCommerce follows the following basic principle and is reasonably easy for anyone with a basic computer knowledge to administer. To complete the following on your own installation of osCommerce - highlight an item by clicking onto it, then click the edit button. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=10&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>1. Initial setup of your Store &#8211; Configuration</h4>
<p>The whole admin section of osCommerce follows the following basic principle and is reasonably easy for anyone with a basic computer knowledge to administer.</p>
<p>To complete the following on your own installation of osCommerce<br />
- highlight an item by clicking onto it, then click the edit button.  Add or update the entry and finally click the update button.</p>
<p>Login to the Admin section of your osCommerce store</p>
<p>Then follow the Configuration link, then the link My Store &#8211; here you should update/change the following:</p>
<p>1. Store name &#8211; The name of the store.<br />
2. Store owner &#8211; The company name that owns the store.<br />
3. E-Mail Address &#8211; The &#8220;from&#8221; email address in the customer&#8217;s order email.<br />
4. E-Mail From &#8211; Your store general email address.<br />
5. Country &#8211; The country you are from.<br />
6. Zone &#8211; The zone your store is located, necessary for taxes later.<br />
7. Send Extra Order Emails To &#8211; The email address to send duplicate order details.</p>
<h4>2. Logo &#8211; adding your own image</h4>
<p>Use FTP to change the default logo</p>
<p>The main logo is located here:<br />
www.your&#8211;domain.com/catalog/images/oscommerce.gif</p>
<p>The easiest method to replace this logo is to over-write the original with your own logo.</p>
<p>Other images that you may find useful to change are located in this folder:<br />
www.your&#8211;domain.com/catalog/images/infobox/</p>
<h4>3. Modify the colours &#8211; the cascading style sheet</h4>
<p>Your sites style sheet</p>
<p>The style and colours of your store are controlled by a single css file:<br />
www.your&#8211;domain.com/catalog/stylesheet.css</p>
<p>Changing the colours, font sizes, font colours, margins, etc. can be done very easily for the entire store using this file.</p>
<p>Detail on how to change css files can be found here: http://www.htmlhelp.com/reference/css/</p>
<h4>4. Further customisation  &#8211; PHP files</h4>
<p>Altering default settings within PHP files</p>
<p>The two PHP files below that hold many default settings including the footer text and page title that appears on all your store pages, and the date format that will be used within your store.</p>
<p>www.your&#8211;domain.com/catalog/includes/languages/english.php<br />
www.your&#8211;domain.com/catalog/includes/languages/english/index.php</p>
<p>Below is a guide to editing PHP files for those that do not have any previous experience of the PHP scripting language.</p>
<p>1.</p>
<p>Copy the following file from your server to your PC:<br />
www.your&#8211;domain.com/catalog/includes/languages/english/index.php</p>
<p>(make a separate backup of the file to a safe location, in case you break the original!).<br />
2.</p>
<p>Then open the file with notepad or your favourite text editor.<br />
3.</p>
<p>On line 23 the following text appears:<br />
define(&#8216;TEXT_MAIN&#8217;, &#8216;Add your own text message here<br />
- open <em>/catalog/index.php</em> and change the text for TEXT_MAIN.&#8217;);<br />
4.</p>
<p>We are going to change the value assigned to TEXT_MAIN to My Store Name.  Change the entry to:</p>
<p>define(&#8216;TEXT_MAIN&#8217;, &#8216;My Store Name.&#8217;);</p>
<p>All we have done is change the text on the right.   The main objective to note here is the text which we changed is on the right between the single quotes (&#8216;), the constant TEXT_MAIN does not change.</p>
<p>You MUST ensure the text you add is within the single quotes.    If you need to add a single quote within the text you are adding for example:<br />
Seiretto&#8217;s Shop<br />
You must add a slash to the text, so it is entered like this:<br />
Seiretto\&#8217;s Shop</p>
<p>Double quotes can be added in the same way.</p>
<p>For more in-depth details see: http://uk.php.net/manual/en/function.define.php</p>
<p>Need to fully modify your hosting account? Then you should consider your own fully managed dedicated server.</p>
<h4>5. TIP &#8211; How to find and alter text phrases on pages of your store</h4>
<p>TIP:  If you wish to change a text phrase displayed on any page of your store and need to find which PHP file holds the details:</p>
<p>1.</p>
<p>Copy the whole of your /catalog/*.* files and sub folders from your server to your own PC.<br />
2.</p>
<p>Select and copy the text phrase which you wish to change from the page on your store.<br />
3.</p>
<p>On you PC highlight the &#8220;\catalog\&#8221; folder and right click your mouse button and select search.<br />
4.</p>
<p>In the input box named  &#8220;Search for files or folders named:&#8221; enter:<br />
*.php<br />
In the input box named &#8220;Containing text:&#8221; paste in your:<br />
text phrase</p>
<h4>5.Then open and edit the PHP file as described here.</h4>
<h4>6. How to remove/modify unwanted languages</h4>
<p>Login to the Admin section of your osCommerce store</p>
<p>Then follow the Localisation link, then the link Languages</p>
<p>- here you should update/change the Languages required.</p>
<p>OR, if you do not need the languages box to appear at all:</p>
<p>1. open the following file with notepad or your favourite text editor:</p>
<p>\includes\boxes\languages.php<br />
2. and delete all contents (note that you are deleting the CONTENTS of the file, and not the file itself).</p>
<h4>7. How to configure to receive copy orders via email</h4>
<p>Login to the Admin section of your osCommerce store</p>
<p>Then follow the Configuration link,</p>
<p>- here you should update/change Send Extra Order Emails To  as required.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=10&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/basic-oscommerce-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>Best joomla tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/best-joomla-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/best-joomla-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 09:57:09 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[JOOMLA]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=8</guid>
		<description><![CDATA[This guide is an in-depth tutorial to the information a Joomla site displays. It details how to plan and organize the information and user experience for the site. It also explains the hierarchy structure currently used in Joomla, sections and categories and how information can be content items, components or modules. In This Guide * [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=8&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This guide is an in-depth tutorial to the information a Joomla site displays. It details how to plan and organize the information and user experience for the site. It also explains the hierarchy structure currently used in Joomla, sections and categories and how information can be content items, components or modules.</p>
<h4>In This Guide</h4>
<p>* How are web pages generated by Joomla?<br />
* What different ways can I present content items?<br />
* How can I organize my content?<br />
* How do components and modules present information?</p>
<h4>Planning Your Content</h4>
<p>Sections and Categories, Static items, Blogs and Tables</p>
<p>One of the hardest parts of Joomla for those new to it to figure out is how content is organized. The relationship between sections, categories, blogs and tables can be very confusing.</p>
<p>To get a better idea of how a Joomla site can be organized, letÙs make a sitemap for an imaginary site. This is a standard planning tool used by web designers and is critical for a Joomla web site. ItÙs usually shown as a tree diagram showing all the pages in the site. Here is our example.</p>
<h4>Example Site Map</h4>
<p>Figure 4-1 A Website Sitemap</p>
<p>In this sitemap, each web page is represented by a box, the lines are links within the site. A sitemap represents viewer path through a site rather than content organization. It is still a useful planning tool for organizing the site however. Here there are seven pages, from an organizational point of view, it seems like there are four main areas of the site:</p>
<p>* About Us<br />
* Widgets<br />
* Contact Us<br />
* Widget Blog</p>
<p>The first step in trying to understand how Joomla structures its content is to realize there are no pages!</p>
<p>OK, so what does that mean?</p>
<p>I talked about the idea of “placeholders” for the content in a CMS like Joomla. Remember, the content is stored in the database and needs to be placed onto the pages by Joomla. The CMS has spaces on its pages to place content and needs to know what content it should put there. Joomla only know what content should be used once you click on a link. Once the viewer has done this, Joomla now knows what page to generate, gets the content, and puts it into place.</p>
<p>Consider a very different example, a magazine. You turn to the index, look something up, get the page number and turn to that page. For that page to be filled with content, the magazine author/designer needed to have chosen the content and arranged it as they wanted on that page. So you turn to it and you see the content. This seems a daft example but it illustrates very well how pages are generated in a CMS. On a Joomla site, you click on a link (the magazine index) and then the content is generated and arranged on the page. So in the magazine case the pages exist before you go to it, but on a Joomla web site, the page only exists once you visit it. Strange but true.</p>
<h4>The Least You Need to Know</h4>
<p>Joomla generates a page the instant you go to visit it.</p>
<p>There are 4 main ways that Joomla generates content:</p>
<p>* Static content<br />
* Dynamic content (organized in sections and categories)<br />
* Components<br />
* Modules</p>
<p>Note that these are not separate pages, in some cases itÙs possible to have more than one type on the same page.<br />
Static Content</p>
<p>In a static site, this very simple sitemap would be 7 simple pages. The simplest ways of creating a site with Joomla is with static content, itÙs much easier to understand how a Joomla site is driven. Static content is just that, a single static content item in the database will correspond to a single page of content on your website; nice and easy.</p>
<h4>The Least You Need to Know</h4>
<p>A single static content item will be a single page on your Joomla site</p>
<p>LetÙs say we have a simple website of three pages, a “Home” page, an “About Us” page and a “Services” page.</p>
<p>Small Site Map Example</p>
<p>In the Content menu is the Static Content Manager. We have two static content items we have created, “About Us” and “Services”. These are created simply clicking the new button. You then get an editor appear and can fill in the information you want (weÙÙ look more at adding content later)</p>
<h4>Static Item Content Manager</h4>
<p>As we just discussed, the hardest things for users to realize about Joomla is that content does not exist by itself on the pages of their website, only in the database. It is only shown on the website when it is linked to in a menu, that is, itÙs the menus that determine the content of a Joomla site, not the content items. Sure, they will be there in the database, but they will only appear once we link to them in a menu somewhere. A consequence of this is that you have to create the content first and then the links to it.</p>
<p>This is true for all content that is in the “main body” of your pages, they must have a link to them to cause them to appear on the site. Just to increase the confusion, they must also be “published” in the content item manager. You can see that our two items above are published. LetÙs create a small menu to point to these two content items.</p>
<h4>The Least You Need To Know</h4>
<p>Menus determine both what will be on a page and how it will be laid out</p>
<p>Tip<br />
An advanced menu technique is possible as the menu that causes the content item to be shown on a page does not need to be published or visible itself. This allows the creation of what I like to call a “landing page menu”. I can create a menu that is not itself published, that links to various other pages. I can then use these in various situations without having to link to them off my site. Maybe I want a special page that offers one of my products at a discount and give the URL in an offline newspaper ad, or a landing page for my Google AdWords campaign. To find these URLÙs, just look at the URL line in the Menu item. This technique is discussed more in the Tips and Tricks Appendix.</p>
<p>Now letÙs head over to the Menu Manager. We create a new menu clicking the New button.</p>
<h4>Menu Module created Dialog</h4>
<p>Figure 4-3 The module created when you make a menu</p>
<p>Note as we create the menu it tells us a “mod_mainmenu” module was created. Take note of that, we will be coming back to it later. “mod_” is just Joomla shorthand for some type of module and “mainmenu” is a type of module that outputs a menu as links.</p>
<p>Now we have our menu, we need to create the links. You can do this one of two ways.</p>
<h4>1. Creating Menu Links from the Menu Manager</h4>
<p>Open the menu you created in the menu manager (select the menu you created from the “Menu” option in the main menu).</p>
<p>Finding New menu<br />
Figure 4-4 Finding the Menu Manager</p>
<p>Then click the “New” button in the top right. Note that the important buttons for any particular page in the Administrator site are always located here.</p>
<p>Clicking on the New button in the top right and you will get lots of choices. WeÙll be looking at these in later chapters, but for now, select “Link – Static Item”. Click the radio button and then click next.</p>
<h4>Creating a New Link</h4>
<p>Figure 4-5 Creating a new link</p>
<p>On the next screen, simply click on what static content item you want to point to and give the link a name. The name given will be the words that shows in the link. This is a critical point for SEO.</p>
<p>The link name does not have to be the same as the title of the static content item. Now, SEO wisdom tells us that the anchor text of a link, the actual words that are “underlined” are very important to achieve a good SERP with that key phrase. This makes our example good for showing what not to do. It would be pointless to try and achieve SERP for the phrase “about us”. If my website sold widgets, then it would make more sense to have a link that said “About our Widgets”, then at least I get Google points for having “widgets” in the link. For the most benefit, the title of the page I am linking to should also have the keyword phrase/anchor text in some version, perhaps “About Widget Inc, your quality supplier for Widgets”.</p>
<p>Now, while we are on link text and SEO, we should mention something else. When making a site care should be taken to make it as “usable” as possible. Usability experts tell us that the words in a link should match very closely the page we end up on. Steve Krug talks about this in his book, saying “if thereÙs a major discrepancy between the link name and the page name, my trust in the site will diminish”.</p>
<p>Taking both these factors into account, trying to place important keywords in the link text and making the link usable, is a balancing act. Often, doing better at one means worse in the other. DonÙt think you can dismiss usability, itÙs no good having good traffic if they all leave your site out of frustration. Needless to say, its work putting some careful thought into what you link text will be. Fortunately, its easy to change later, you just go and edit the menu item.</p>
<h4>The Least You Need to Know</h4>
<p>You can create links to a content item, but the content needs to exist first<br />
The names of a link (anchor text) needs to be chosen very carefully</p>
<p>Back to static items.</p>
<h4>2. Creating Menu Links from the Content Item</h4>
<p>We mentioned another way of creating menu links, and itÙs probably an easier one. As you create a content item, there are 5 panels/tabs on the right hand side: Publishing, Images, Parameters, Meta Info and Link to Menu.</p>
<p>Note:<br />
The content item must be saved before these tabs appear. Click “Apply” rather than “Save” and then they will be loaded.</p>
<h4>Creating a new static content item</h4>
<p>Figure 4-6 Creating a New Static Item</p>
<p>Creating the menu link is as easy as selecting the menu you want the link to appear on, selecting the type (not shown here as this is a static content item) and the “Link to Menu” button. Note, however, the menu must exist already before you can use this method.</p>
<p>So, we now have a site with a couple of pages, a menu that links to two static content items to show the on the website.</p>
<p>On to the last page on our site, the home page. Now we start getting to some of the aspects of Joomla that are more difficult to understand. The default set up for Joomla installation is that the home page is not a static page or a dynamic section/category; itÙs actually a special component.</p>
<h4>The Least You Need to Know</h4>
<p>You can create a menu link as you create a content item, you have to save the item first so you can see the menu options.<br />
Component Content</p>
<h4>The Front Page Component</h4>
<p>We saw when we were selecting what type of link to have that that a menu link can link to a component. The default Joomla installation has a number of pages that are actually components: the contact us page, the search page, the news feeds page and lastly the front page component. None of these really have content items of their own, but pull their content from various places, either within the Joomla site database (contacts) or even other sites (RSS newsfeeds). Basically a component is a mini application that presents data in the main body of a Joomla site in some fashion. A good example of a component is a forum. The content presented is highly specialized and different from the rest of the site.</p>
<p>In almost every case (except this one) all components installed are in the Components menu. The Frontpage component is unique in Joomla in that it is not managed from anything in the Components menu, but rather in the Frontpage Manager in the Content menu. Quite simply the Frontpage component allows the publishing of any content item in a Joomla siteÙs database on the front/home page regardless of where it appears on the site.</p>
<p>The home page of your site doesnÙt have to be controlled by the Frontpage manager. Sometimes more control over its layout is needed, or some other requirement. The first item in the main menu will be the home page of your site. In the default Joomla installation this is set to be the Frontpage manager, but it could just as easily be a static content item, a table, or another component. Just remember, whatever is first in the list will be your front page or home page. One thing you need to be careful of is some issues with item ID with this relationship. For more information read this thread on the Official forum.joomla.org/index.php/topic,4259.0.html.</p>
<h4>The Least You Need to Know</h4>
<p>Components are mini-applications that present content in the main body is a special way<br />
The home page of a Joomla site is a component. It allows you to pull content from anywhere in your site for the home page</p>
<p>A quick look at the Content Items Manager and you will see a column that controls if an item appears on the front page. You can simply click on these crosses and check marks to publish/unpublish items onto the front page. You can also change this setting in the publishing tab in the actual content item itself.</p>
<h4>The Content Items Manager</h4>
<p>This is a good example of a page that “does not exist”. What we actually mean by this is that the content is dynamically generated the instant you view the page. In the case of this dynamic page, the content is taken from other database locations to populate the home page. This concept of dynamically generated content is one of the main differences between CMS sites and static ones. You canÙt change a static page unless you go in and change (X)HTML in a file somewhere. In a dynamic CMS you can change content with a simple click of your mouse.</p>
<p>In the example we are using, a site of just 3 pages illustrates the important difference between static content items and dynamic content. In this site our home page would be empty. So far we have only 2 content items and they are both static. A static item cannot be “pulled” into other pages like a general content item. It has a 1 to 1 item to page correspondence. General content items however can appear on several pages.</p>
<h4>Static and dynamic content</h4>
<p>It is not a complete free for all in how you insert content into a page. You are limited by how you can manipulate the hierarchical content structure that Joomla uses to organize its content; sections and categories</p>
<p>The other components in the default installation of Joomla are:<br />
Name 	Description<br />
Banners 	Manages advertising banners<br />
Contacts 	Manages contacts<br />
Mass Mail 	Sends out email to all users<br />
News Feeds 	Manages newsfeeds from other sites<br />
Polls 	Manages dynamic voting polls<br />
Syndicate 	Manages RSS syndication<br />
Web Links 	Manages simple web link directory<br />
Dynamic Content<br />
How Joomla Organizes Content: Sections and Categories</p>
<p>LetÙs go back to the example we started with, our 7 page site. Now that we have a better idea of what dynamic content is we can think not in terms of pages but in terms of content items.</p>
<p>We know that two of these pages will be special components, the home page and the contact us page. A component is basically a special page that does something unusual to the content in presenting it. That leaves us with 5 other pages. We can see that there are actually 7 content items here:</p>
<p>1. About Us<br />
2. Services Description<br />
3. Widget Blog Description<br />
4. TodayÙs blog<br />
5. YesterdayÙs blog<br />
6. Green Widgets<br />
7. Blue Widgets</p>
<p>Joomla gives us two organizational structures, first sections, and then inside that, categories.</p>
<p>Tip<br />
In the Joomla roadmap are plans to change the hierarchical structure to be infinite categories.</p>
<p>At first glance, our structure might seem obvious, leaving out the two components, we have three sections:</p>
<p>* About Us<br />
* Services<br />
* Widget blog</p>
<p>Now, things start getting complicated.</p>
<p>You canÙt put content items in a section, they must go in a category. This means that each section needs at least one category.</p>
<p>A frequently used analogy is a filing cabinet. In the cabinet you have drop down folders, inside them you have manila folders and inside those sheets of paper with content on them.</p>
<h4> How Joomla stores its content</h4>
<p>The filing cabinet is the website, the dropdown folders are the sections, the manila folders are the categories and the paper is the content. To continue the example, static content would be loose sheets of paper in a stack at the bottom of the cabinet. ThatÙs why bigger sites need to use the section/category model, it organizes the information. I am not sure what a component would be, maybe a rolodex on top of the cabinet.</p>
<p>So one way to organize our content might be like this:<br />
Sections 	About Us 	Services 	Widget Blog</p>
<h4>Categories</h4>
<p>About Us 	Blue Widgets<br />
Green Widgets 	Widget Blog</p>
<p>The services categories work fine and make sense, the other two seem to duplicate the content level. This is because the content hierarchy for that area is only one “level” deep. You end up with a redundant level.</p>
<h4>There are two solutions to this.</h4>
<p>First and perhaps the easiest is to make all single level items static content. We have already seen that this is easy to set up. The down side is that the site can quickly become difficult to maintain. I have found this to happen with many more than 10-15 static items, mainly because Joomla provides no organization for them, they are all lumped into one group.</p>
<p>The second solution is to be more creative with our sections/categories. For example, we could have just a single section, letÙs call it “AllContent”. Then we have all the sections inside it:</p>
<h4>Sections</h4>
<p>AllContent<br />
Categories 	About Us<br />
Blue Widgets<br />
Green Widgets<br />
Widget Blog</p>
<p>Or we might have something in between. This problem often occurs with smaller sites with not too much content. In those instances you have to get creative.</p>
<p>In our example it might be good to use both. A single static item for About Us and then two sections for Services and the blog. The Widget Blog is a good candidate for its own category and section because they tend to have lots of entries. Even though there is a redundant layer of structure, it will easier to keep organized in the site.</p>
<p>The Least You Need to Know<br />
Content items must be in a category which must be in a section. This can lead to a redundant organizational level for small sites<br />
There are many ways to organize the same set of content in a Joomla site</p>
<h4>Module Content</h4>
<p>The last type of content is a module. The content presented in a module is very different to static or dynamic content, or components. In all three of the first types, the content is presented in the main body of the web pages. The template designer actually has to give a snippet of code to set the “placeholder”. Modules however can be anywhere on page. Most commonly you will find them around the edges; the top, sides and bottom.</p>
<p>Having said that modules are a type of content, that is not strictly true. Some types of module take in data rather than output data. An example of this is the login module. The default modules on a default Joomla installation are:<br />
Name 	Description<br />
Banner 	Shows banners from banner component<br />
Menu 	Presents links of a menu<br />
Login Form 	Shows a form to log in or create account<br />
Syndicate 	Shows RSS feed links that viewers can use to syndicate to the home page<br />
Statistics 	Shows various site stats<br />
Template Chooser 	Allows user to change template of site on the fly<br />
Archive 	This module shows a list of the calendar months, which contain Archived items.<br />
Sections 	Shows a list of all Sections configured in your database<br />
Related Items 	Shows links of content items that have similar keywords<br />
Wrapper 	Presents another URL inside an iframe (a page within a page)<br />
Polls 	Shows polls from the poll component<br />
WhoÙs Online 	Shows number of viewers currently on the site<br />
Random Image 	Shows a random image<br />
Newsflash 	Shows a random content item from a chosen category<br />
Latest News 	Shows link list to most recently published content items<br />
Popular 	Shows link list of most popular content items (by page view)<br />
Search 	Shows a search box<br />
User 	A special module that is created by the administrator. It can contain either RSS feeds or any sort of html.</p>
<p>We wonÙt go into too much detail about how modules work. There are a number of settings/parameters related to their function in the index.php, the template file that controls all the presentation on the site. A more detailed developers guide to dev.joomla.org/content/view/1136/79/</p>
<h4>Guide Summary</h4>
<p>* Joomla is a dynamic content management system. Web pages are generated by the server software at the very instant you visit them. One implication of this is that in Joomla, the menus actually determine the content and layout of a web page.<br />
* Joomla has two main types of content, static and dynamic. Static content has a 1 to 1 relationship between content items and web pages. This is not true for dynamic content, a single page can hold many items and vice versa.<br />
* Joomla has a 3 level content organizational hierarchy. Content items are held in Categories which are held in Sections. In the current versions of Joomla, all dynamic content must follow this organization. This can sometimes lead to a redundant level for small sites.<br />
* Content is also presented by components and modules. Components are mini applications that run inside Joomla, like a forum. Modules even smaller functions relating to the site, for example a log in form or a poll. Components are always presented in the mainbody, modules are usually output in side columns or header/footers.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=8&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/best-joomla-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>
	</item>
		<item>
		<title>50 WordPress Tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/50-wordpress-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/50-wordpress-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 09:47:59 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[WORDPRESS]]></category>
		<category><![CDATA[PLUGINS]]></category>
		<category><![CDATA[SIDEBAR]]></category>
		<category><![CDATA[WEBSITE]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=4</guid>
		<description><![CDATA[WordPress Basics 1. Unraveling the Secrets of the comments.php File Nettuts+ author Gilles Maes has written an in-depth overview of the comments.php file and how to make the most of the template. 2. How to Become a WordPress Developer iThemes has a tutorial on how to become a WordPress developer. The article covers development tools, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=4&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>WordPress Basics</h3>
<h4>1. Unraveling the Secrets of the comments.php File</h4>
<p>Nettuts+ author Gilles Maes has written an in-depth <a rel="nofollow" href="http://nettuts.com/news/unraveling-the-secrets-of-wordpress-commentsphp-file/">overview of the comments.php file</a> and how to make the most of the template.</p>
<h4>2. How to Become a WordPress Developer</h4>
<p><a rel="nofollow" href="http://www.ithemes.com/">iThemes</a> has a tutorial on <a rel="nofollow" href="http://ithemes.com/the-wordpress-developer-toolkit/">how to become a WordPress developer</a>. The article covers development tools, best plugins, suggestions for getting clients, and more.</p>
<h4>3. Multiple WordPress Installations Using a Single Database</h4>
<p>Streamline your WordPress set-up by installing multiple instances of WordPress on <a rel="nofollow" href="http://www.optiniche.com/blog/392/multiple-installs-single-database/">the same database</a>.</p>
<h3>Theme Tutorials</h3>
<h4>4. How to Create a WordPress Theme from Scratch</h4>
<p>Nettuts+ author Sam Parkinson gives a thorough overview of <a rel="nofollow" href="http://nettuts.com/site-builds/how-to-create-a-wordpress-theme-from-scratch/">how to make your own custom theme from scratch</a>, complete with source code.</p>
<h4>5. So You Want to Create WordPress Themes, Huh?</h4>
<p>A lengthy and thorough <a rel="nofollow" href="http://www.wpdesigner.com/2007/02/19/so-you-want-to-create-wordpress-themes-huh/">series of tutorials</a> covering nearly every aspect of WordPress theme development. A must-read for beginners.</p>
<h4>6. WordPress for Designers: Video Series</h4>
<p>Drew Douglass will teach us, using easy to understand screencasts, exactly <a href="http://en.support.wordpress.com/affiliate-links/">how to design for WordPress.</a></p>
<h4>7. WordPress Theme Hacks</h4>
<p>A collection of <a rel="nofollow" href="http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/">simple WordPress hacks</a> that you&#8217;ll find yourself reusing all the time when working with themes.</p>
<h4>8. Designing for WordPress Screencast</h4>
<p><a rel="nofollow" href="http://css-tricks.com/">CSSTricks</a> has an excellent 3-step screencast that starts with the <a rel="nofollow" href="http://css-tricks.com/video-screencasts/25-designing-for-wordpress-part-one/">basics of solid theme design</a> (<a rel="nofollow" href="http://css-tricks.com/video-screencasts/26-designing-for-wordpress-part-two/">step 2</a> and <a rel="nofollow" href="http://css-tricks.com/video-screencasts/27-designing-for-wordpress-part-three/">step 3</a>).</p>
<h4>9. Turning a Web Template Into a WordPress Theme</h4>
<p>Instead of using one of the many standard WordPress themes, you could <a rel="nofollow" href="http://max.limpag.com/2006/09/01/video-tutorial-wordpress-theme/">convert a web template into a WordPress theme</a> with this video tutorial.</p>
<h4>10. WordPress CSS Guides</h4>
<p>A slightly-dated but still useful guide on <a rel="nofollow" href="http://www.tamba2.org.uk/wordpress/graphicalcss/">how to alter the CSS on default themes</a> to create your own personalized theme.</p>
<h4>11. How to Create a WordPress Theme in 5 Minutes</h4>
<p><a rel="nofollow" href="http://www.bothack.wordpress.com/">Bothack</a> has a quick-n-dirty rundown on how to <a rel="nofollow" href="http://bothack.wordpress.com/2006/09/17/how-to-create-a-wordpress-template-in-5-minutes/">create your own WordPress theme in 5 minutes</a>.</p>
<h4>12. Mastering WordPress Theme Hacks and Techniques</h4>
<p><a rel="nofollow" href="http://www.nuope.com/">Nuope</a> has a 4-part series on <a rel="nofollow" href="http://www.noupe.com/tutorial/the-powerful-guide-to-master-your-wordpress.html">Mastering CSS</a>, one of which is <a rel="nofollow" href="http://www.noupe.com/wordpress/mastering-your-wordpress-theme-hacks-and-techniques.html">how to master WordPress theme hacks</a>.</p>
<h4>13. Blog Posts in Different Columns</h4>
<p>If you&#8217;re wanting a little more advanced look and feel to your blog, try <a rel="nofollow" href="http://www.cre8d-design.com/2006/03/wordpress-tutorial-blog-posts-in-different-columns/">setting the posts to display in different columns</a>.</p>
<h4>14. Adding Tabs to Your Theme&#8217;s Sidebar</h4>
<p>Here&#8217;s a quick hack that <a rel="nofollow" href="http://rubiqube.com/wordpress-tutorial-adding-tabs-to-your-blog-sidebar/">adds tabs to your sidebar</a> using <a rel="nofollow" href="http://developer.yahoo.com/yui/tabview/">Yahoo! Tab View</a>.</p>
<h4>15. Category Styling</h4>
<p>This tutorial shows how to add messages in the theme for <a rel="nofollow" href="http://vandelaydesign.com/blog/wordpress/category-styling/">posts in a certain category</a> using CSS.</p>
<h4>16. Multiple Page Layouts in a Single Template</h4>
<p>If you&#8217;re looking for a more diversified template for sub-pages in a template, check out <a rel="nofollow" href="http://www.darrenhoyt.com/2007/12/26/multiple-wordpress-page-layouts-in-one-single-template/">this quick tutorial for mutiple page layouts in a single template</a>.</p>
<h4>17. Rounded Corner Tab Menus</h4>
<p><a rel="nofollow" href="http://rubiqube.com/">Rubique</a> has a quick tutorial on how to use CSS to <a rel="nofollow" href="http://rubiqube.com/wordpress-tutorial-rounded-corner-tab-menu-using-css/">make rounded corners</a> for your WordPress menus.</p>
<h4>18. Dynamic Classes or ID&#8217;s</h4>
<p><a rel="nofollow" href="http://elliotjaystocks.com/">Elliot Jay Stocks</a> as a useful tutorial on how to <a rel="nofollow" href="http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/">apply a dynamic body class or ID to your templates</a>, for styling purposes.</p>
<h4>19. Formatting Images for Feed Readers</h4>
<p>How to <a rel="nofollow" href="http://www.pearsonified.com/2007/06/how-to-format-images-for-feed-readers.php">make sure your images are looking good</a> in many of your blog follower&#8217;s favorite medium: the feed reader.</p>
<h4>20. How to Highlight Author Comments in WordPress</h4>
<p>Google blogger <a rel="nofollow" href="http://www.mattcutts.com/">Matt Cutts</a> offers some advice on <a rel="nofollow" href="http://www.mattcutts.com/blog/highlight-author-comments-wordpress/">how to style your author comments</a> differently than the rest of the reader comments.</p>
<h4>21. Customizing Widgets Using CSS</h4>
<p>Widgets are a great way to quickly add information to your layout (namely the sidebar). Here&#8217;s a tutorial on <a rel="nofollow" href="http://rubiqube.com/wordpress-tutorial-customizing-widgets-using-css/">how to style the widgets using CSS</a>.</p>
<h4>22. Using Sliding Doors with WordPress Navigation</h4>
<p>The <a rel="nofollow" href="http://www.alistapart.com/articles/slidingdoors/">Sliding Doors</a> technique is a great way to utilize CSS and background images to make tabbed navigation. WPHacks shows us <a rel="nofollow" href="http://wphacks.com/sliding-doors-wordpress-navigation-css-technique/">how to utilize Sliding Doors to enhance WordPress navigation</a>.</p>
<h4>23. WordPress Categories in a Horizontal Drop-down Menu</h4>
<p>How to use CSS and Javascript to make a <a rel="nofollow" href="http://anthologyoi.com/wordpress/displaying-wordpress-categories-in-a-horizontal-dropdown-menu.html">horizontal drop-down menubar</a>.</p>
<h4>24. Separate Comments from Trackbacks</h4>
<p>It&#8217;s a good idea to <a rel="nofollow" href="http://wphacks.com/how-to-separate-wordpress-comments-and-trackbacks/">separate trackbacks from your comments</a>.</p>
<h4>25. Creating a Widget Ready Footer</h4>
<p>There&#8217;s a trend for blogs to have footers that feature columns of extra information. Learn how to create a <a rel="nofollow" href="http://help-developer.com/index.php/2008/07/creating-a-widget-ready-footer-in-wordpress/">widget-ready WordPress footer</a>.</p>
<h4>26. Make a Featured Post Carousel</h4>
<p>Many blogs use a featured post carousel to show recent posts or flagship content. <a rel="nofollow" href="http://nettuts.com/working-with-cmss/how-to-make-a-featured-post-carousel-for-wordpress/">Learn how to create this nifty feature</a> with Nettuts+ author James Lao.</p>
<h4>27. How to Lay Text Over Images</h4>
<p>Add a little flair to your blog and <a rel="nofollow" href="http://5thirtyone.com/archives/875">add some text to your flagship images</a> by only using WordPress custom fields.</p>
<h4>28. The Date/Image Hack</h4>
<p><a rel="nofollow" href="http://www.yugatech.com/blog/wordpress/wp-date-image-hack/">Interesting tutorial</a> on how to combine a combination of images, CSS and WordPress hooks in order to graphically display the date of the published post.</p>
<h4>29. Dynamic Sticky Pages</h4>
<p>Learn how to <a rel="nofollow" href="http://www.maxpower.ca/wordpress-hack-creating-a-dynamic-sticky/2005/04/23/">dynamically make posts stay on top longer</a> in category and archive listings using multiple loops.</p>
<div><img style="display:inline;" src="http://nettuts.s3.amazonaws.com/066_WordpressThemeFromScratch/3.jpg" alt="" /></div>
<h3>Plugins</h3>
<h4>30. Your First WP Plugin</h4>
<p>Mark Jaquith has a short-and-sweet screencast on how to create <a rel="nofollow" href="http://markjaquith.wordpress.com/2006/03/04/wp-tutorial-your-first-wp-plugin/">your first WordPress plugin</a> in under 5 minutes.</p>
<h4>31. How to Write a Simple WordPress Plugin</h4>
<p>A <a rel="nofollow" href="http://asymptomatic.net/2005/02/22/1350/how-to-write-a-simple-wordpress-plugin">step-by-step guide</a> to a simple and fun WordPress plugin.</p>
<h4>32. Screencast on Writing a WordPress Plugins</h4>
<p>If you&#8217;re rather see a visual demonstration of how to write a WordPress plugin, look no further than the <a rel="nofollow" href="http://weblogtoolsvideos.com/video/How-to-make-a-wordpress-plugi">Weblog Tools Collection screencast</a>.</p>
<div><img style="display:inline;" src="http://nettuts.s3.amazonaws.com/016_UserLinkFeed/7.jpg" alt="" /></div>
<h3>The Backend</h3>
<h4>33. Custom Write Panels in the WordPress Backend</h4>
<p>Design blog <a rel="nofollow" href="http://www.wefunction.com/">WeFunction</a> shows us how to <a rel="nofollow" href="http://wefunction.com/2008/10/tutorial-creating-custom-write-panels-in-wordpress/">create extra write panels</a> for adding extra bits to the &#8220;Write&#8221; page of the admin area.</p>
<h4>34. WordPress as a CMS</h4>
<p>WordPress isn&#8217;t just a blogging tool, <a rel="nofollow" href="http://css-tricks.com/video-screencasts/41-wordpress-as-a-cms/">it can also be a CMS</a> with the help of some plugins and theme retooling.</p>
<h4>35. Exporting WordPress Data</h4>
<p>Learn how to import and export your WordPress posts and comments with <a rel="nofollow" href="http://wordpresstraining.com/videos/install-and-configure/import-and-export-wordpress-data/#more-19">this handy screencast</a>.</p>
<div><img style="display:inline;" src="http://nettuts.s3.amazonaws.com/218_50wptuts/custom_write_panel.jpg" alt="" /></div>
<h3>Miscellaneous</h3>
<h4>36. Embedding WordPress into OS Commerce</h4>
<p><a rel="nofollow" href="http://www.oscommerce.com/">OS Commerce</a> is a popular open source ecommerce shopping script that many web developers use to sell goods. Here&#8217;s a tutorial on <a rel="nofollow" href="http://michaelwender.com/2005/11/28/embedding-wordpress-into-os-commerce/">how to embed a WordPress blog into an OS Commerce installation</a>.</p>
<h4>37. Creating An Automatic Sitemap</h4>
<p>Sitemaps help users navigate the site, as well as allow search engines to have quick access to all of your blog&#8217;s pages. Here&#8217;s a tutorial on how to create an <a rel="nofollow" href="http://www.jimwestergren.com/tutorial-automatic-sitemap-in-wordpress/">automatic sitemap</a> for your WordPress installation.</p>
<h4>38. Build a Dynamic Design Portfolio</h4>
<p>A terrific guide on how to utilize the <em>query_posts</em> tag to <a rel="nofollow" href="http://www.darrenhoyt.com/2007/08/24/build-a-dynamic-design-portfolio-with-wordpress/">create a design portfolio with WordPress</a>.</p>
<h4>39. Create a User Contributed Link Feed w/ WordPress Comments</h4>
<p>If you&#8217;re wanting to add a Nettuts+ style link feed, Collis has an excellent tutorial on <a rel="nofollow" href="http://nettuts.com/working-with-cmss/hack-together-a-user-contributed-link-feed-with-wordpress-comments/">how to utilize WordPress comments to create the feed</a>.</p>
<h4>40. A WordPress-Powered Membership Directory</h4>
<p><a rel="nofollow" href="http://www.wpdesigner.com/">WPDesigner</a> shows us how to <a rel="nofollow" href="http://www.wpdesigner.com/2008/03/01/how-to-use-wordpress-as-a-membership-directory/">create a membership directory using a standard installation of WordPress</a> and some customization.</p>
<h4>41. Remove Categories in the WordPress Loop</h4>
<p>Sometimes excluding certain posts in categories from showing in the WordPress loop is important. Here&#8217;s a quick tutorial with sample code on <a rel="nofollow" href="http://bloggercamp.com/blogging-tips/blogging-tips-wordpress-tips/remove-several-categories-from-the-loop-in-wordpress/">how to exclude certain categories</a> in your templates.</p>
<h4>42. Add a Twitter Field to your Form</h4>
<p><a rel="nofollow" href="http://vimeo.com/2326653">How to install the twitip-id plugin</a> to include a field for commenters to leave their Twitter ID.</p>
<h4>43. Enabling HTTPS for WordPress.com Blogs Screencast</h4>
<p>The <a rel="nofollow" href="http://www.wordpress.org/">WordPress team</a> has put together a how-to video on <a rel="nofollow" href="http://support.wordpress.com/https/">enabling HTTPS</a> on WordPress.com blogs.</p>
<h4>44. How to Add Photo Captions</h4>
<p>Good photo captions aren&#8217;t that something that WordPress themes usually come with out of the box. This screencast shows how to correctly <a rel="nofollow" href="http://www.viddler.com/explore/Miss604/videos/11/">add photo captions</a> into your posts.</p>
<h4>45. Make a Random Post Button</h4>
<p><a rel="nofollow" href="http://wpguy.com/tutorials/how-to-make-a-random-post-button/">Adding a random post button</a> is only a SQL query and PHP snippet away.</p>
<h4>46. RSS-Only Posts</h4>
<p>This tutorial shows you <a rel="nofollow" href="http://courtneytuttle.com/2007/12/06/creating-posts-that-appear-only-in-rss/">how to create posts that only appear in RSS feeds</a>, in hopes to improve RSS subscriber counts.</p>
<h4>47. WordPress SEO</h4>
<p><a rel="nofollow" href="http://yoast.com/">Yaost</a> has a lengthy tutorial on how to <a rel="nofollow" href="http://yoast.com/articles/wordpress-seo/">squeeze the most SEO out of your WordPress blog</a>.</p>
<h4>48. Learn How to Make Your Blog Accessible</h4>
<p>Most blogs don&#8217;t conform to WAI/WCAG standards in terms of accessibility. Learn how to meet these standards with Bruce Lawson&#8217;s <a rel="nofollow" href="http://www.brucelawson.co.uk/2005/wordpress-accessibility-hacks/">accessibility hacks</a>.</p>
<h4>49. Definitive Guide to Semantic Web Markup for Blogs</h4>
<p>Although not strictly a WordPress tutorial, Chris Pearson&#8217;s <a rel="nofollow" href="http://www.pearsonified.com/2007/04/definitive-guide-to-semantic-markup.php">guide to semantic web markup for blogs</a> is a must-read for anyone wanting to maximize their results in search engines.</p>
<h4>50. Digg-proof Your WordPress</h4>
<p><a rel="nofollow" href="http://blog.circlesixdesign.com/2007/01/22/diggproof/">Learn how to configure</a> MySQL, Apache and other things to keep your site humming when it lands on the front page of Digg.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=4&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/50-wordpress-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/066_WordpressThemeFromScratch/3.jpg" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/016_UserLinkFeed/7.jpg" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/218_50wptuts/custom_write_panel.jpg" medium="image" />
	</item>
		<item>
		<title>PHP Basic tutorials</title>
		<link>http://uttammitra.wordpress.com/2009/10/23/php-basic-tutorials/</link>
		<comments>http://uttammitra.wordpress.com/2009/10/23/php-basic-tutorials/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 05:19:42 +0000</pubDate>
		<dc:creator>uttammitra</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[JOOMLA]]></category>
		<category><![CDATA[WORDPRESS]]></category>

		<guid isPermaLink="false">http://uttammitra.wordpress.com/?p=17</guid>
		<description><![CDATA[PHP is a powerful scripting language that fits gracefully into HTML and puts the tools for creating dynamic websites in the hands of the people &#8212; even people like me who were too lazy to learn Perl scripting and other complicated backend hoodoo. This tutorial is for the person who understands HTML but doesn&#8217;t know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=17&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>PHP is a powerful scripting language that fits gracefully into HTML and puts the tools for creating dynamic websites in the hands of the people &#8212; even people like me who were too lazy to learn Perl scripting and other complicated backend hoodoo.</p>
<p>This tutorial is for the person who understands HTML but doesn&#8217;t know much about PHP. One of PHP&#8217;s greatest attributes is that it&#8217;s a freely distributed open-source language, so there&#8217;s all kinds of excellent reference material about it out there, which means that once you understand the basics, it&#8217;s easy to find the materials that you need to push your skills.</p>
<p><em>This tutorial, originally submitted by Webmonkey contributor Tim Ziegler, is a <strong>wiki</strong>. Please help us keep it up to date. If you have extra advice, log in and add it.</em></p>
<h2>Introduction</h2>
<p><a name="What_Is_PHP.3F"></a></p>
<h3>What Is PHP?</h3>
<p>So, what is this whole PHP business all about?</p>
<p>PHP is a program that gets installed on top of your web server software. It works with versions of Apache (<a title="Tutorial:Apache for Beginners" href="http://www.webmonkey.com/tutorial/Apache_for_Beginners">Tutorial:Apache for Beginners</a>), Microsoft IIS and other server software packages.</p>
<p>You use PHP by inserting PHP code inside the HTML that makes up your website. When a client (anybody on the web) visits a web page that contains this code, your server executes it. That&#8217;s why you need to install your own server in order to test PHP locally &#8212; the server is the brain here, not your browser. Users don&#8217;t need any special plug-ins or anything to see your PHP in action &#8212; it gets to the end user as regular old-fashioned HTML.</p>
<p>PHP is a scripting language, like HTML. That means that code does not need to be compiled before it gets used &#8212; it gets processed on the fly as necessary.</p>
<p>Before we dig in, you should know about a site called <a title="http://www.php.net/" rel="nofollow" href="http://www.php.net/">PHP.net</a>. PHP is an open-source language, and PHP.net is its control center, with extensive reference material about the language and tips sent in by users across the globe. PHP.net has exceptional, deep information about the language, but it can be a little cryptic for the newcomer. We&#8217;ll look more closely at how to use PHP.net at the end of this tutorial.</p>
<p>So, what kinds of things can PHP do? Welllll &#8230; it can:</p>
<ul>
<li> take info from web-based forms and use it in a million ways (store it in a database, create conditional pages depending on what the forms said, set cookies for later, send e-mail, write your mom on her birthday);</li>
</ul>
<ul>
<li> authenticate and track users;</li>
</ul>
<ul>
<li> run threaded discussions on your site;</li>
</ul>
<ul>
<li> serve different pages to people using different browsers or devices;</li>
</ul>
<ul>
<li> publish an entire website using just a single layout template (server-side includes-style);</li>
</ul>
<ul>
<li> serve XML pages.</li>
</ul>
<p>But before we can get to the specific uses of PHP, we need to start with a quick preview of the building blocks of PHP, beginning with a sample script. This example script is titled &#8220;chickenman.php.&#8221; When called by a web browser, it would simply read, &#8220;I am the CHICKEN MAN!&#8221;</p>
<pre>    &lt;?php

    print ("I am the CHICKEN MAN");

    ?&gt;
</pre>
<p>The <tt> ?php</tt> and <tt>?¢</tt> tags start and end a PHP script, and your meat goes in the middle. Got that? Good! Now let&#8217;s walk through the basic rules you need to know to before you can write your first PHP script.</p>
<p><a name="What_you.27ll_need"></a></p>
<h2>What you&#8217;ll need</h2>
<p>Before we begin, you will need to install a server on your own machine in order to test your PHP scripts locally. You can install WampServer for Windows machines from <a title="http://www.wampserver.com/en/" rel="nofollow" href="http://www.wampserver.com/en/">http://www.wampserver.com/en/</a> In order to have a Localhost machine.  If you&#8217;re using a Mac you can get MAMP from <a title="http://www.mamp.info" rel="nofollow" href="http://www.mamp.info/">http://www.mamp.info</a>.</p>
<p>If you have space on a web server which supports PHP, you can also test your PHP there, but this is kind of a pain because it means you&#8217;ll need to FTP your files or telnet in every time you want to change something.</p>
<p><a name="Steps"></a></p>
<h2>Steps</h2>
<p><a name="The_Basics"></a></p>
<h3>The Basics</h3>
<p>The code itself fits right inside a page&#8217;s HTML, and like HTML it is made up of plain ol&#8217; text. So a page that displays the words &#8220;I am the CHICKEN MAN!&#8221; message would sit inside an HTML page named <em>something.php,</em> like this:</p>
<table border="0">
<tbody>
<tr>
<td bgcolor="#cccccc">
<pre>1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.</pre>
</td>
<td bgcolor="#cccccc">
<pre>&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt; Chicken Man Example &lt;/title&gt;
 &lt;/head&gt;

 &lt;body&gt;

 &lt;font color="red"&gt;My PHP code makes this page say:&lt;/font&gt;

 &lt;p&gt;

 &lt;?php

 print ("I am the CHICKEN MAN");

 ?&gt;
 &lt;/p&gt;

 &lt;/body&gt;
 &lt;/html&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>See how that works? The HTML is rendered as regular HTML, but everything inside the <tt> ?php</tt> and <tt>?¢</tt> tags gets processed as PHP.</p>
<p><a name="Basic_Syntax"></a></p>
<h4>Basic Syntax</h4>
<p>It&#8217;s time to write your own first PHP script. The basic rules of PHP are as follows:</p>
<p><strong>Naming Files</strong> In order to get a PHP script working, the file it&#8217;s in or the file that it calls to do the heavy lifting must end in <em>.php</em> (earlier versions used the file extensions .php3 and .phtml). Like HTML, your files are saved as plain text.</p>
<p><strong>Comments</strong> It&#8217;s important to get in the habit of leaving notes about your code with the comment tags so that months down the road you can make sense of what you were trying to make your script do. The way you set comments apart from your code (that you don&#8217;t want displayed or executed) is with either &#8220;//&#8221; at the beginning of each line, or surrounded by &#8220;/*&#8221; and &#8220;*/&#8221; if you want to comment out several lines:</p>
<pre>&lt;?php

// This will be ignored. Note to self:
// Pick up ice cream, cake, and balloons.

print ("I am the CHICKEN MAN");

/*
This, too, will be ignored.
Hey, and don't forget
the spanking machine!
*/

?&gt;
</pre>
<p><a name="Code_Syntax"></a></p>
<h4>Code Syntax</h4>
<p><strong>Start of Code</strong> Every piece of PHP code begins with &#8220;&lt;?php&#8221; (or the abbreviated &#8220;&lt;?&#8221; if your server is configured to handle that).</p>
<p><strong>End of Code</strong> The way to signify that the PHP code is finished is by adding &#8220;?&gt;&#8221; at the end.</p>
<p><strong>Every Chunk</strong> With a few exceptions, each separate instruction that you write will end with a semicolon.</p>
<p><strong>Parentheses</strong> The typical function looks like this &#8230;</p>
<pre>print ( );
</pre>
<p>&#8230; where &#8220;print&#8221; is the function and the stuff that the function works on sits inside the parentheses, with a semicolon to finish it off. (Just to confuse you, &#8220;print&#8221; is the exception that also works without parentheses.) By the way, echo () is the same as print ().</p>
<p>Much like HTML, the actual formatting of your PHP code (where you put spaces, line breaks, etc.) will not affect the outcome except those parts of the code that tell a web browser how to display your page. So this piece of code &#8230;</p>
<pre>&lt;?php

    print ("I am the CHICKEN MAN");

    ?&gt;

... is effectively identical to:

    &lt;?php print ("I am the CHICKEN MAN"); ?&gt;
</pre>
<p>Like more complicated HTML, it behooves you to use white space and tabs in your code to make the code more understandable.</p>
<p>Ready to write your first script? Let&#8217;s go.</p>
<p><a name="Your_First_Script"></a></p>
<h3>Your First Script</h3>
<p>OK, so write your first script already! Copy the following script, but put whatever you want inside the quotation marks. &#8220;Print&#8221; here means print to the screen of a web browser when you open the file:</p>
<pre>&lt;html&gt;
&lt;body&gt;

  &lt;?php

  print ("I am the CHICKEN MAN");

  ?&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Save the file with any name that has no spaces and ends in .php, and if you&#8217;ve installed a server on your own machine, you need to save the script somewhere inside the server&#8217;s root folder (on Windows this is typically in the &#8220;wwwroot&#8221; directory inside the &#8220;inetpub&#8221; directory on your C: drive).</p>
<p>The next step is to open the file in your browser. Since you need the server to run your PHP code, you have to open the file through a URL that finds the correct file through your web server. On Windows, your computer name is your root URL. My computer name is &#8220;rocketboy,&#8221; so to see the contents of my root directory, I type &#8220;http://rocketboy&#8221; into the Web browser and voila! I see the contents of my root folder. To open the file &#8220;chickenman.php&#8221; in a directory called &#8220;tests&#8221; inside the root directory, I&#8217;d type &#8220;http://rocketboy/tests/chickenman.php&#8221; and see my example.</p>
<p>If you&#8217;re testing on a PHP-able web server, FTP your files anywhere on your server and they should work when you open them through the URL.</p>
<p>Go on now and get your first script working. Then come back and we&#8217;ll have some fun. Together. (If you can&#8217;t get your first script working, look at our <a title="http://www.wired.com/wired/webmonkey/stuff/PHP_Tutorial_troubleshoot1.html" rel="nofollow" href="http://www.wired.com/wired/webmonkey/stuff/PHP_Tutorial_troubleshoot1.html">First Script Troubleshooting Guide</a>.)</p>
<p><a name="Error_Messages"></a></p>
<h3>Error Messages</h3>
<p>Fun, eh? Fun if it worked. If not &#8212; if you had an error in your script &#8212; you probably got an error message that looked something like this:</p>
<pre>Parse error:
parse error in C:\Inetpub\wwwroot\webmonkey_article\test9.php
on line 12
</pre>
<p>Error messages can be very useful and you&#8217;re bound to run into lots of them. You&#8217;ll get a message like this for every line in your script that has an error. For our purposes, all we really need to know is that there is something wrong with our code in line 12 of the document &#8220;test9.php,&#8221; so let&#8217;s look at that line and see if we can figure it out (good text editors like BBEdit have a function that lets you jump to any particular line). I always start by looking to see if my basic syntax is correct: did I leave out the closing tag, a line&#8217;s semicolon, quotation marks?</p>
<p><a name="A_Few_More_Statements"></a></p>
<h3>A Few More Statements</h3>
<p>Let&#8217;s continue by adding to your test code from the last page to show a couple useful tools.</p>
<p>In the same code that you wrote before, drop in a couple more statements. As you see, you can gang up more than one PHP function inside the same opening and closing tags. My comments in the code explain what each part does:</p>
<pre>    &lt;html&gt;
    &lt;body&gt;

    This text right here (or any HTML I want to write)
    will show up just before the PHP code stuff.
    &lt;p&gt;

    &lt;?php

    // first, this $PHP_SELF thang is
    // an environment variable that'll show the
    // path from your root folder to this
    // document itself, like /webmonkey_article/test3.php.
    // I put this in just for fun.
    // NOTE: This may only work if your server is Apache.

    print "$PHP_SELF";

    // next we have to "print" any
    // HTML code we want the browser
    // to follow to determine
    // the layout of the results page.
    // In this case, we're adding a &lt;p&gt; tag
    // the &lt;p&gt; tags could have been put
    // inside the same print statement as the
    // "I am the CHICKEN MAN" text.
    // between the $PHP_SELF text and the
    // next bunch of stuff.

    print ("&lt;p&gt;");

    print ("I am the CHICKEN MAN");

    print ("&lt;p&gt;");

    /* This next "phpinfo" business outputs a long page that
    tells you exactly how your version of PHP is configured.
    This can be useful when troubleshooting problems down
    the road */

    phpinfo();

    ?&gt;
    &lt;/p&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</pre>
<p>NOTE: Phpinfo will output a long page of info about your version of PHP. You don&#8217;t need to understand what it all means, I just wanted to show you that it&#8217;s there if you ever need it.</p>
<p><a name="Very_Able_Variables"></a></p>
<h3>Very Able Variables</h3>
<p>So far, all we&#8217;ve done is have a PHP script print some text. Big whoop. Let&#8217;s get down and dirty now with variables. A variable is a container for holding one or more values. It is the means by which PHP stores information and passes it along between documents and functions and such. You may remember variables from algebra &#8212; in the equation &#8220;x + 2 = 8&#8243;, x is a variable with the value 6.</p>
<p>The reason why variables are so important to PHP is that the very notion of having dynamic web pages &#8212; pages which respond somehow to user input &#8212; relies on data being passed around between pages (or parts of a page). Variables are the main mechanism for transferring data like this.</p>
<p>I think the easiest way to explain how variables work in PHP is to show them in action. There are three basic things you can do with variables:</p>
<ol>
<li> Set them (give them one or more values);</li>
<li> Re-set them if they were set before;</li>
<li> Access them (read the value of a variable and then do something useful with it).</li>
</ol>
<p>Variables in PHP start with a dollar sign (&#8220;$&#8221;). Below I am setting a variable, using it, then setting and using it again. The value that a variable holds can be changed any time at all.</p>
<pre>1. &lt;?php
2. $utterance = "I love you!";
3. print ("When I'm happy, I want to say $utterance");
4. print ("&lt;p&gt;");
5. $utterance = "I will smite you!";
6. print ("When I'm angry, I want to say $utterance");
7. ?&gt;
</pre>
<p>Here&#8217;s what that page will look like:</p>
<p><img src="http://www.wired.com/wired/webmonkey/stuff/PHP_Tutorial_utterance.gif" alt="PHP_Tutorial_utterance.gif" /></p>
<p>In line two I have created a variable that I decided to name &#8220;utterance.&#8221; All variables start with &#8220;$&#8221;, so my variable is written &#8220;$utterance&#8221; in the code. Here&#8217;s how that last code snippet breaks down line by line. Please note: the webserver does the PHP interpreting before sending the browser finished HTML code.</p>
<ul>
<li> Line 1 tells the webserver: &#8220;Start PHP code here&#8221;.</li>
</ul>
<ul>
<li> Line 2 creates the variable $utterance and also sets it, giving it the initial value of &#8220;I love you!&#8221;.</li>
</ul>
<ul>
<li> Line 3 prints a phrase that draws on the variable $utterance.</li>
</ul>
<ul>
<li> Line 4 creates atag in HTML to put vertical space between the two utterances.</li>
</ul>
<ul>
<li> Line 5 RE-SETS the variable $utterance and gives it the value &#8220;I will smite you!&#8221;.</li>
</ul>
<ul>
<li> Line 6 prints a new phrase that draws on the new meaning of the variable $utterance.</li>
</ul>
<ul>
<li> Line 7 tells Mr. Webserver: PHP code ends here.</li>
</ul>
<p>See how the variable <tt>$utterance</tt> is used as a sort of container that can hold different values? We just set and then called variables inside the same script, but the power of PHP is that you can set a variable in one place &#8212; say from a form that a user fills out &#8212; and then use that variable later.</p>
<p>The syntax of setting a variable is to:</p>
<ul>
<li> define it with the = sign ($utterance = &#8220;I love you!&#8221;;);</li>
</ul>
<ul>
<li> use quotation marks if you&#8217;re defining it with a string of letters (&#8220;I love you!&#8221;; numbers don&#8217;t require quotes);</li>
</ul>
<ul>
<li> end each instruction with a semicolon.</li>
</ul>
<p>Then you call it by refering to the variable name ($utterance in lines 3 and 6 &#8212; notice no quotation marks there).</p>
<p><a name="Naming_Variables"></a></p>
<h4>Naming Variables</h4>
<p>You can name a variable anything you want so long as it follows these rules:</p>
<ul>
<li> it starts with a letter;</li>
</ul>
<ul>
<li> it is made up of letters, numbers, and the underscore character (that&#8217;s the _ character, as in &#8220;$baby_names&#8221;);</li>
</ul>
<ul>
<li> it isn&#8217;t used elsewhere (like &#8220;print&#8221;).</li>
</ul>
<p>Warning: Variable names are case-sensitive, so $baby_names and $Baby_names are not the same. You also should try to make your names have some meaning so that you can still make sense of your code next year.</p>
<p>In the examples so far, we have set variables as chunks of text, which are known as &#8220;strings.&#8221; Variables can also hold the values of numbers and some other things as well (objects, arrays, booleans).</p>
<p>Final note: One thing that can be a little confusing when starting to use PHP is the use of quotation marks inside PHP functions. Use single or double quotes to set off strings (that is, chunks of text), as in:</p>
<pre>    print ("I am the CHICKEN MAN");
</pre>
<p>This will print the text I am the CHICKEN MAN. If you want to display quotation marks as characters in the output of your PHP script, you must escape them with the &#8220;\&#8221; character, which tells PHP not to use the next character as part of the code. So to output the text &#8220;I am the CHICKEN MAN&#8221; (with quotation marks showing in the result) the code would look like:</p>
<pre>    print (" \"I am the CHICKEN MAN\"" );
</pre>
<p><a name="HTML_Forms_and_PHP"></a></p>
<h3>HTML Forms and PHP</h3>
<p>In our examples so far, we have set variables and then used them all in the same code. This doesn&#8217;t make much sense because in those instances, we could have just hard-coded the values instead of using variables.</p>
<p>Let&#8217;s get some real mileage by creating HTML forms to gather user input, turning that input into variables, and then doing various things with the information that we just collected.</p>
<p>No sense in sitting around waiting &#8211; let&#8217;s go ahead and make a Web page that collects your favorite dirty word and displays it on another page that tells you what a pervert you are. All of this gives a page that looks a lot like <a title="http://www.hulagrrl.com/webmonkey/badwords_form.html" rel="nofollow" href="http://www.hulagrrl.com/webmonkey/badwords_form.html">this</a>.</p>
<p>First, we make the form page, which is regular HTML with a form in it. I&#8217;m calling mine &#8220;badwords_form.html,&#8221; but call yours whatever you like. (If you want a good primer on HTML forms, read Jay&#8217;s How To <a title="Tutorial:Add HTML Forms to Your Site" href="http://www.webmonkey.com/tutorial/Add_HTML_Forms_to_Your_Site"> Add HTML Forms to Your Site</a> tutorial.)</p>
<table border="0" width="400">
<tbody>
<tr>
<td bgcolor="#cccccc">
<pre>1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.</pre>
</td>
<td bgcolor="#cccccc">
<pre>&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;My Form&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt; 

 &lt;form action="bad_words.php" method=post&gt; 

 My name is:
 &lt;br&gt; &lt;input type="text" name="YourName"&gt; 

 My favorite dirty word is:
 &lt;br /&gt;&lt;input type="text" name="FavoriteWord"&gt; 

 &lt;input type="submit" name="submit" value="That's Right!"&gt;
 &lt;/form&gt;

 &lt;/body&gt;
 &lt;/html&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>This is a regular HTML form. The important pieces are as follows:</p>
<p>Line 7: the HTML that reads <tt>action="bad_words.php"</tt> tells the browser which PHP document will process the results of the form. That is to say, in a minute you&#8217;ll create a document called &#8220;bad_words.php&#8221; which will be the little engine that makes the result page happen. (We&#8217;ll get to the <tt>method=post</tt> part later on.)</p>
<p>Line 10: <tt>input type="text"</tt> determines that the form element which we want here is &#8220;text&#8221; or a text box (we could also have a radio button, check box, etc.); <tt>name="YourName"</tt> determines that whatever the user types into the text box will become a variable that we have called &#8220;YourName.&#8221; This is what ties together forms and variables &#8211; each form field can set a variable to be used however you want.</p>
<p>Line 13: here you have another text input that sets a variable called &#8220;FavoriteWord&#8221; which is the user&#8217;s favorite dirty word.</p>
<p>Line 16, 17: This code makes a submit button with the text &#8220;That&#8217;s Right!&#8221; and ends the form.</p>
<p>So this form will collect the unassuming user&#8217;s name and favorite bad word, but now what do we do with it? Let&#8217;s take the variables she set and echo them back in another context on another page.</p>
<p>On line 7 of the HTML above, we told the form to head on over to <tt>bad_words.php</tt> once the submit button was hit. This is what <tt>bad_words.php</tt> looks like:</p>
<table border="0" width="400">
<tbody>
<tr>
<td bgcolor="#cccccc">
<pre>1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.</pre>
</td>
<td bgcolor="#cccccc">
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Perv!&lt;/title&gt;
&lt;/head&gt;

&lt;?php
// Capture the values posted to this php program from the text fields
// which were named 'YourName' and 'FavoriteWord' respectively

$YourName = $_REQUEST['YourName'] ;
$FavoriteWord = $_REQUEST['FavoriteWord'] ;
?&gt;

&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;p&gt;

Hi &lt;?php print $YourName; ?&gt;

&lt;p&gt;

You like the word &lt;b&gt; &lt;?php print $FavoriteWord; ?&gt;!?!&lt;/b&gt;

&lt;p&gt;You oughta be ashamed of yourself!

&lt;/body&gt;

&lt;/html&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>See how this form passed a variable along from the form page to the PHP file? You have not seen the last of <em>this.</em></p>
<p><a name="Get_versus_Post"></a></p>
<h4>Get versus Post</h4>
<p>So far, we&#8217;ve used the &#8220;Post&#8221; method of passing form data as opposed to the other method, &#8220;Get.&#8221; This is the part of the form code that reads <tt> form action="bad_words.php" method=post¢</tt>.</p>
<p>The difference between these two is that the &#8220;post&#8221; method transparently passes along all the information the page has gathered, whereas the &#8220;get&#8221; method will pass all that info along as part of the URL (in the form above, this would look like: <a title="http://rocketboy/webmonkey_article/bad_words.php?YourName=bob&amp;FavoriteWord=crikey%21&amp;submit=Enter+My+Data%21" rel="nofollow" href="http://rocketboy/webmonkey_article/bad_words.php?YourName=bob&amp;FavoriteWord=crikey%21&amp;submit=Enter+My+Data%21">http://rocketboy/webmonkey_article/bad_words.php?YourName=bob&amp;FavoriteWord=crikey%21&amp;submit=Enter+My+Data%21</a> &#8211; see how the info the user entered about his name and his favorite word get added to the URL?)</p>
<p><a name="Arrays"></a></p>
<h3>Arrays</h3>
<p>One of your best tools now that you&#8217;ve mastered variables &#8211; you have, haven&#8217;t you? &#8211; are arrays.</p>
<p>Arrays give you the ability to store not just one value inside a variable, but a whole bunch of values in a single variable.</p>
<p>If I wanted to catalog all of the animals in my house, I could set each one as a regular variable. I&#8217;ve got two dogs, Phoebe and Ruby, and a squirrel that died in the attic last year, whom we&#8217;ll call Rotty. Setting each one as a variable looks like this:</p>
<pre>$dog1 = "Phoebe";
$dog2 = "Ruby";
$squirrel1 = "Rotty";
</pre>
<p>But an array will let us store all these inside one single variable, which I&#8217;ll call $critters. Each element of the variable has its own &#8220;key&#8221; that is used to access that part of the array, which can either be a string of letters or numbers.</p>
<p>Let me explain the &#8220;key&#8221; concept another way: If we&#8217;re storing three different values inside one variable (like storing Phoebe, Ruby, and Rotty inside $critters), we need some way to be able to suck out any individual part of the array to use it. An array will automatically number each element that comprises it, so the key can be element 1, element 2, and element 3. Or, as we&#8217;ll see later on, we can name each part of the array with text. In this case I could make the keys &#8220;fat dog,&#8221; &#8220;skinny dog,&#8221; and &#8220;squirrel&#8221; and use those to identify each array member.</p>
<p>Let&#8217;s make a simple array and then use it. The easiest way to create an array is to use the array() function, which assigns a bunch of values to your array at once and looks like this:</p>
<pre>    $critters = array ( "Phoebe", "Ruby", "Rotty" );
</pre>
<p>This stores all my animal names into one variable ($critters) in an array, and automatically assigns a numbered &#8220;key&#8221; to each element starting in order and giving the first element the number 0. So Phoebe is element [0], Ruby is [1], Rotty is [2], etc. I make up the name of the array myself (here it&#8217;s $critters).</p>
<p>You can now get at any of the array elements by referring to the variable followed by the element number in square brackets: $critters[0], for example. Here it is in action:</p>
<pre>&lt;?php

    print "$critters[2]";

    ?&gt;
</pre>
<p>This will simply print the third element in the array, which is Rotty (don&#8217;t forget that array numbers start at 0, so $critters[2] is third after $critters[0] and $critters[1]).</p>
<p>There&#8217;s another way to set an array, or even to add to an existing array, by setting each element individually:</p>
<pre> $critters[] = "Phoebe";
    $critters[] = "Ruby";
    $critters[] = "Rotty";
</pre>
<p>This&#8217;ll have the same effect as using the array() function, giving the first element the key [0] and so on. But wait! I forgot about Opie the cat. Hmmm. Regardless of how we made the array in the first place, I can easily add Opie like this:</p>
<pre>    $critters[] = "Opie";
</pre>
<p>PHP is smart enough to count the number of elements and give Opie the next available one, which in this case (after Phoebe, Ruby, and Rotty) is [3].</p>
<p>To recap this concept, I can set an array to include the animals in my house either this way:</p>
<pre>    $critters[] = "Phoebe";
    $critters[] = "Ruby";
    $critters[] = "Rotty";
    $critters[] = "Opie";
</pre>
<p>Or this way:</p>
<pre>    $critters = array ( "Phoebe", "Ruby", "Rotty", "Opie" );
</pre>
<p>Both will be indexed in the computer brain with the values:</p>
<pre>    $critters[0] = "Phoebe";
    $critters[1] = "Ruby";
    $critters[2] = "Rotty";
    $critters[3] = "Opie";
</pre>
<p>And in both cases, you could get at any element in the array by describing its number &#8230;</p>
<pre> &lt;?php

    print "$critters[3]";

    ?&gt;
</pre>
<p>&#8230; which would print the string Opie to the window of your browser.</p>
<p>Arrays can be made to do all kinds of things, like being incremented by number, sorted in alphabetical order, printed by different types of categorization, and many more.</p>
<p><a name="Associative_Arrays"></a></p>
<h3>Associative Arrays</h3>
<p>Ready to get more complicated? The associative array indexes the contained elements not by numbers, but by names that you determine. Inside the array() function, you set up pairs where you name the key and its value using the combo of the &#8220;=&#8221; and the &#8220;&gt;&#8221;, like: key=&gt;&#8221;value&#8221;. Here&#8217;s what it looks like in action:</p>
<pre>  $PhoebeDog = array (
    		name=&gt;"Phoebe",
    		description=&gt;"fat dog",
    		color=&gt;"grey and white",
    		age=&gt;7
   				);
</pre>
<p>Here we&#8217;re telling the array to create the keys &#8220;name,&#8221; &#8220;description,&#8221; &#8220;color,&#8221; and &#8220;age&#8221;; and we give each of those keys a value (name is &#8220;Phoebe&#8221;, description is &#8220;fat dog,&#8221; and so on).</p>
<p>We can get at any part of the array through the &#8220;key&#8221; names that we set, for example:</p>
<pre>    print $PhoebeDog[color];
</pre>
<p>will give us grey and white. We can also set each key individually, like so:</p>
<pre>    $animals[name] = "Phoebe";
    $animals[description] = "fat dog";
    $animals[color] = "grey and white";
    $animals[age] = 7;
</pre>
<p>Finally, let&#8217;s make it hurt. We&#8217;re going to get some serious power out of this arrays business by creating a &#8220;multi-dimensional&#8221; array. A multi-dimensional array is an array (say the animals in my house) that is made up of other arrays (for each animal, an array that contains the critter&#8217;s name, color, description, and age).</p>
<p>We make multi-dimensional arrays by creating one array:</p>
<pre>    $animals = array
            (
    			);
</pre>
<p>&#8230;and then we fill that array with an array of animals in which we&#8217;ve defined the keys, like this:</p>
<pre>    $animals = array (
    		array ( name=&gt;"Phoebe",
    			    type=&gt;"dog",
    			    color=&gt;"grey and white",
    			    age=&gt;7 ),
    		array ( name=&gt;"Ruby",
    			    type=&gt;"dog",
    			    color=&gt;"brown and white",
    			    age=&gt;7 ),
    		array ( name=&gt;"Rotty",
    			    type=&gt;"squirrel",
    			    color=&gt;"grey",
    			    age=&gt;2 ),
    		array ( name=&gt;"Opie",
    			    type=&gt;"cat",
    			    color=&gt;"grey tabby",
    			    age=&gt;5 )
    					);
</pre>
<p>To use this now, we can get any part of the information contained in there by naming the overall array ($animals), naming the number of the sub-array that we want to find out about (Phoebe is [0], Ruby is [1], etc.) and then naming the key for the attribute we want to get at (name, type, color, or age).</p>
<p>To find out the age of the cat, we&#8217;d write:</p>
<pre>print $animals[3][age];
</pre>
<p>Here&#8217;s what it all looks like together. This is all in one page, but remember that you can set arrays in one place (in code or in form fields from another page or in a database, say) and get at the info contained within from somewhere else. Here I&#8217;m putting it all together on one page so you can see it all at once.</p>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Pet Arrays&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php

$animals = array (
		array ( name =&gt; "Phoebe",
				type =&gt; "dog",
				color =&gt; "grey and white",
				age =&gt; 7 ),
		array ( name =&gt; "Ruby",
				type =&gt; "dog",
				color =&gt; "brown and white",
				age =&gt;7 ),
		array ( name =&gt; "Rotty",
				type =&gt; "squirrel",
				color =&gt; "grey",
				age =&gt;2 ),
		array ( name =&gt; "Opie",
				type =&gt; "cat",
				color =&gt; "grey tabby",
				age =&gt; 5 )
					);

print $animals[2]["type"];
print ("&lt;br&gt;");
print $animals[3]["color"];

?&gt;	

&lt;/body&gt;&lt;/html&gt;
</pre>
<p>What we&#8217;ve just done is create an array that includes a sub-array for each animal which contains detailed info about that critter; then we print a sentence that uses the type and ages of two of the animals.</p>
<p><a name="Operators.3B_If.2C_Else.2C_Elseif.3B_Loops"></a></p>
<h3>Operators; If, Else, Elseif; Loops</h3>
<p>The whole deal about making dynamic websites is that you want your web page to be as smart as possible &#8212; to have code sitting there that can make all sorts of decisions based on different kinds of user input, user conditions (what browser is Visitor X using?), or information that you set yourself. Examples of this could be:</p>
<ul>
<li> After a user enters an email address, check that it has a valid form (whoever@wherever.com) and if not, serve a page that says, &#8220;hey pal, how about a VALID email address?&#8221;</li>
</ul>
<ul>
<li> Serve one set of HTML to .com domains and another to .gov domains (where you try not to use any big words that might confuse &#8216;em).</li>
</ul>
<ul>
<li> Know whether a customer at your online store is meeting a minimum dollar amount for an online credit card purchase.</li>
</ul>
<ul>
<li> And on and on and on &#8211; the possibilities are limitless.</li>
</ul>
<p><a name="If"></a></p>
<h4>If</h4>
<p>The way to make your pages smart is to use If, Else, and Elseif statements along with Comparison and Logical Operators. The most important one of these is the</p>
<pre>if</pre>
<p>statement, which gives you the ability to code:</p>
<pre>    If some condition is true, then do somesuch thing;
    If the condition is not true, then ignore it;
</pre>
<p>The syntax of this statement is as follows:</p>
<pre> if (condition) {

// code in here to execute if the condition is true

}
</pre>
<p>Here it is in action. First we set the variable</p>
<pre>    &lt;?php

    $FavoriteColor = "blue";

    if ($FavoriteColor == "blue") {

    print ("I like blue too!");

    }

    ?&gt;
</pre>
<p>Please note that:</p>
<pre>if ($FavoriteColor = "blue")
</pre>
<p>and</p>
<pre>if ($FavoriteColor == "blue")
</pre>
<p>are not the same thing, the first will always be true as it sets $FavoriteColor to blue.</p>
<p><a name="Else"></a></p>
<h4>Else</h4>
<p>Else builds on the if statement as if to say:</p>
<pre>    If some condition is true, then do somesuch thing;
    ELSE, in case that first condition is NOT true, then do this other thing.
</pre>
<p>It works like this:</p>
<pre>if (condition) {

// code in here to execute if the condition is true

} else {

// code in here to execute if the condition is not true

}
</pre>
<p>Here it is in motion:</p>
<pre>&lt;?php

$FavoriteColor = "yellow";

if ($FavoriteColor == "blue") {

print ("I like blue too!");

} else {

print ("You don't like blue?! Crazy fool!");

}

?&gt;
</pre>
<p>What you see above is the typical format for writing statements like this. The key part is to see where the curly braces are so you don&#8217;t get confused as to which statement belongs to which piece of the code. Above, the first set of { and } belong to the &#8220;if,&#8221; the second { and } belong to the &#8220;else.&#8221;</p>
<p><a name="Elseif"></a></p>
<h4>Elseif</h4>
<p>There&#8217;s one more sibling in the <tt>if, else</tt> family, and it&#8217;s called <tt>elseif</tt>. Where else is sort of a blanket control that make something happen as long as the <tt>if</tt> statement is not true, <tt>elseif</tt> makes something happen if a specific condition is met:</p>
<pre>IF some condition is true, then do somesuch thing;
    ELSEIF some other specific condition is true, then do another thing;
</pre>
<p>It looks like this:</p>
<pre>&lt;?php

    $FavoriteColor = "green";

    if ($FavoriteColor == "blue") {

    print ("I like blue too!");

    } elseif ($FavoriteColor = green) {

    print ("MMMmmmmmmmmmm, green!");

    }

    ?&gt;
</pre>
<p>You could even add an ELSE statement at the end in case FavoriteColor were neither blue nor green.</p>
<p><a name="Comparison_and_Logical_Operators"></a></p>
<h3>Comparison and Logical Operators</h3>
<p>We&#8217;ve seen how the &#8220;=&#8221; sign works when we set variables in the scripts we&#8217;ve written so far (as in the code <tt>$FavoriteColor = "blue";</tt> and <tt>$utterance = "I will smite you!";</tt> ). The equal sign here is what we call the &#8220;assignment operator&#8221; and is the simplest operator we&#8217;ve got: <tt>$a = b</tt> means &#8220;the variable a is assigned the value b (for the moment).&#8221;</p>
<p>But you can squeeze a lot more juice out of your PHP using what are called &#8220;comparison operators,&#8221; &#8220;logical operators,&#8221; and &#8220;arithmetic operators.&#8221; Here&#8217;s what they are, in tables copied verbatim from <a title="http://www.php.net" rel="nofollow" href="http://www.php.net/">PHP.net</a>.</p>
<p><a name="Comparison_Operators"></a></p>
<h4>Comparison Operators</h4>
<p>These give you the ability to compare whether elements are equal, identical, less than or greater than one another (with some other variations).</p>
<table border="1">
<tbody>
<tr>
<th align="left" valign="center"> Example</th>
<th align="left" valign="center"> Name</th>
<th align="left" valign="center"> Result</th>
</tr>
<tr>
<td align="left" valign="center">$a == $b</td>
<td align="left" valign="center">Equal</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is equal to $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a === $b</td>
<td align="left" valign="center">Identical</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is equal to $b, and they are of the same type. (PHP 4 only)</td>
</tr>
<tr>
<td align="left" valign="center">$a != $b</td>
<td align="left" valign="center">Not equal</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is not equal to $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a &lt;&gt; $b</td>
<td align="left" valign="center">Not equal</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is not equal to $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a !== $b</td>
<td align="left" valign="center">Not identical</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is not equal to $b, or they are not of the same type. (PHP 4 only)</td>
</tr>
<tr>
<td align="left" valign="center">$a &lt; $b</td>
<td align="left" valign="center">Less than</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is strictly less than $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a &gt; $b</td>
<td align="left" valign="center">Greater than</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is strictly greater than $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a &lt;= $b</td>
<td align="left" valign="center">Less than or equal to</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is less than or equal to $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a &gt;= $b</td>
<td align="left" valign="center">Greater than or equal to</td>
<td align="left" valign="center"><strong>TRUE</strong> if $a is greater than or equal to $b.</td>
</tr>
</tbody>
</table>
<p><a name="Logical_Operators"></a></p>
<h4>Logical Operators</h4>
<p>Here you can compare elements using comparisons and, or, and the like.</p>
<table border="1">
<tbody>
<tr>
<th align="LEFT" valign="MIDDLE"> Example</th>
<th align="LEFT" valign="MIDDLE"> Name</th>
<th align="LEFT" valign="MIDDLE"> Result</th>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">$a and $b</td>
<td align="LEFT" valign="MIDDLE">And</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if both $a and $b are <strong>TRUE</strong>.</td>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">$a or $b</td>
<td align="LEFT" valign="MIDDLE">Or</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if either $a or $b is <strong>TRUE</strong>.</td>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">$a xor $b</td>
<td align="LEFT" valign="MIDDLE">Xor</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if either $a or $b is <strong>TRUE</strong>, but not both.</td>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">! $a</td>
<td align="LEFT" valign="MIDDLE">Not</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if $a is not <strong>TRUE</strong>.</td>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">$a &amp;&amp; $b</td>
<td align="LEFT" valign="MIDDLE">And</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if both $a and $b are <strong>TRUE</strong>.</td>
</tr>
<tr>
<td align="LEFT" valign="MIDDLE">$a || $b</td>
<td align="LEFT" valign="MIDDLE">Or</td>
<td align="LEFT" valign="MIDDLE"><strong>TRUE</strong> if either $a or $b is <strong>TRUE</strong>.</td>
</tr>
</tbody>
</table>
<p><a name="Aritmetic_Operators"></a></p>
<h4>Aritmetic Operators</h4>
<p>Just what it says &#8211; this is basic math.</p>
<table border="1" width="367">
<tbody>
<tr>
<th align="left" valign="center"> Example</th>
<th align="left" valign="center"> Name</th>
<th align="left" valign="center"> Result</th>
</tr>
<tr>
<td align="left" valign="center">$a + $b</td>
<td align="left" valign="center">Addition</td>
<td align="left" valign="center">Sum of $a and $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a &#8211; $b</td>
<td align="left" valign="center">Subtraction</td>
<td align="left" valign="center">Difference of $a and $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a * $b</td>
<td align="left" valign="center">Multiplication</td>
<td align="left" valign="center">Product of $a and $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a / $b</td>
<td align="left" valign="center">Division</td>
<td align="left" valign="center">Quotient of $a and $b.</td>
</tr>
<tr>
<td align="left" valign="center">$a % $b</td>
<td align="left" valign="center">Modulus</td>
<td align="left" valign="center">Remainder of $a divided by $b.</td>
</tr>
</tbody>
</table>
<p><a name="Loops"></a></p>
<h3>Loops</h3>
<p>Loops are really handy. They let you program your code to repeat itself (and also to figure out how many times to run through itself before it&#8217;s done). Loops have instructions to &#8220;keep running this piece of code over and over again until certain conditions are met.&#8221; You can use more than one kind of loop. Let&#8217;s look at the most basic kind, the &#8220;while&#8221; loop.</p>
<p>The while loop says,</p>
<pre>while (something is true)

{

// do something that you specify

}
</pre>
<p>While loops are often used with incrementing and decrementing a variable that is an integer. What in the <em>hell</em> does that mean? It means that you can automatically have the script add (or subtract) a whole number (1, 2, 3, etc.) from part of a script each time it runs through, until the number reaches a maximum or minimum value that you&#8217;ve set.</p>
<p>So if you wanted a script to print the numbers from 1 to 10, you can tell it (this is English, not PHP here):</p>
<pre>a. the variable $MyNumber = 1;

b. print $MyNumber;

c. add 1 to $MyNumber;

d. go to sep a. and run this script again with the new value of $MyNumber;

d. stop when $MyNumber reaches 11;
</pre>
<p>The syntax for incrementing and decrementing the value of a variable is:</p>
<table border="1" cellpadding="3">
<tbody>
<tr>
<td>$a++;</td>
<td>adds 1 to the value of the variable $a each time through</td>
</tr>
<tr>
<td>$a&#8211;;</td>
<td>subtracts 1 from the value of the variable $a each time through</td>
</tr>
</tbody>
</table>
<p>So the code itself for printing the numbers 1 through 10 could look like this:</p>
<table border="0" width="300">
<tbody>
<tr>
<td bgcolor="#cccccc">
<pre>1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.</pre>
</td>
<td bgcolor="#cccccc">
<pre>&lt;?php 

$MyNumber = 1;

while ($MyNumber &lt;= 10)

{ 

print ("$MyNumber"); 

$MyNumber++; 

}

 ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
<ul>
<li> line 1: start PHP code;</li>
</ul>
<ul>
<li> line 3: set variable $MyNumber to 1;</li>
</ul>
<ul>
<li> line 5: initiate &#8220;while&#8221; loop: while the variable $MyNumber is less than or equal to 10, execute what&#8217;s below; otherwise move on;</li>
</ul>
<ul>
<li> line 9: print the current value of $MyNumber;</li>
</ul>
<ul>
<li> line 11: add 1 to the value of $MyNumber;</li>
</ul>
<ul>
<li> line 15: end PHP code.</li>
</ul>
<p>For these loops, you can use all the &#8220;operators&#8221; listed on the section above to be the conditions that must be met before the loop stops.</p>
<p><a name="Other_Loops"></a></p>
<h4>Other Loops</h4>
<p>PHP has other kinds of loops, but they are beyond the scope of this tutorial. If you want to learn what they are and how to use them, follow these links to PHP.net:</p>
<ul>
<li> <a title="http://www.php.net/manual/en/control-structures.do.while.php" rel="nofollow" href="http://www.php.net/manual/en/control-structures.do.while.php">do..while loop</a></li>
<li> <a title="http://www.php.net/manual/en/control-structures.for.php" rel="nofollow" href="http://www.php.net/manual/en/control-structures.for.php">for loop</a></li>
<li> <a title="http://www.php.net/manual/en/control-structures.foreach.php" rel="nofollow" href="http://www.php.net/manual/en/control-structures.foreach.php">foreach loop<br />
</a></li>
</ul>
<p><a name="Functions"></a></p>
<h3>Functions</h3>
<p>If you&#8217;ve used HTML a lot, you know that it&#8217;s a pretty limited language that was designed back in the dark ages before we all knew what the Net was capable of.</p>
<p>PHP, however, is very flexible. Not only does PHP have a library of canned functions that&#8217;ll do everything from sorting stuff in alphabetical order to sending email, from connecting with databases to balancing your spaceship&#8217;s inertial sub-space dampers, but you can also create your very own functions to do all manner of things related to your website. The functions you create get executed exactly like those from the PHP library, but they&#8217;re your own. In the following section, I&#8217;ll show a glimpse of how you create your own functions and feel the power.</p>
<p>Functions you create are like little machines that do something for you. You construct them and then call them as needed.</p>
<p>You&#8217;ll remember that the very first thing we learned to do was a simple &#8220;print&#8221; statement, which followed the form:</p>
<pre>    &lt;?php

    print ("whatever it is I want to show up on-screen");

    ?&gt;
</pre>
<p>Functions that you create are built upon a similar form, but take it farther:</p>
<pre>&lt;?php

function MyFunction ()

{

statements that make up the function;

}

?&gt;
</pre>
<p>So you start a function with the words <tt>function WhatYouNameIt()</tt>, with the words WhatYouNameIt() being anything you choose (no spaces).</p>
<p>Then you define the rules of the function inside the following curly brackets (that&#8217;s { and } on lines 5 and 9). Don&#8217;t you just love the words &#8220;curly brackets?&#8221;</p>
<p>Let&#8217;s walk through the making of a couple functions. Functions come in two flavors, those that require &#8220;arguments&#8221; and those that don&#8217;t. An &#8220;argument&#8221; is a variable that comes from outside the function, but which the function needs in order to run.</p>
<p>Let&#8217;s first look at one that doesn&#8217;t require arguments:</p>
<pre>&lt;?php

function ChickenMan()

{

print "&lt;b&gt;I am the CHICKEN MAN!&lt;/b&gt;";

}

ChickenMan();

?&gt;
</pre>
<p>line 1: start PHP;<br />
line 3: create function ChickenMan;<br />
line 5: start definition of function ChickenMan;<br />
line 7: definition of ChickenMan is to print &#8220;I am the CHICKEN MAN!&#8221; inside <strong> and </strong> tags;<br />
line 9: end definition of ChickenMan;<br />
line 11: call function ChickenMan (meaning &#8220;do the thing that we defined the function to do&#8221;);<br />
line 13: close PHP;</p>
<p>Any place in this web page that you put &#8220;ChickenMan();&#8221; inside the &lt;?php and ?&gt; tags, it&#8217;ll print your little statement. See how this saves you time if you want to print this string a bunch of times in different places?</p>
<p>Now let&#8217;s get a little more complicated and create a function that does take arguments. Say I&#8217;m a loan shark and I&#8217;m going to loan you the money to buy that <a title="http://www.rqriley.com/imagespln/peg1.jpg" rel="nofollow" href="http://www.rqriley.com/imagespln/peg1.jpg">personal hovercraft</a> you&#8217;ve been lusting after. I&#8217;ll lend you however much you need, but you have to pay me 14 percent interest per week or I break your legs.</p>
<p>I&#8217;ll create a function called InterestPayment which calculates your weekly payments (until you pay off the whole loan amount in one lump sum).</p>
<p>First we&#8217;ll create a form page where the user enters how much of a loan he or she wants. The user enters the hovercraft&#8217;s sticker price, and that number gets passed along from the form as a variable called <tt> font size="2"&gt;$Cost</tt>. (For the HTML behind this, go <a title="http://www.wired.com/wired/webmonkey/stuff/loanshark_html.html" rel="nofollow" href="http://www.wired.com/wired/webmonkey/stuff/loanshark_html.html">here</a>.)</p>
<p>Next, our function will take the amount that the user enters into the variable <tt> font size="2"&gt;$Cost</tt> and spit back 14 percent of that amount, which is how much the hapless borrower owes every week. This will happen in the PHP page titled &#8220;loanshark.php&#8221; that the form page points to (it points with this code: &lt;form action=&#8221;loanshark.php&#8221; method=post&gt; ). Here&#8217;s what the function will look like:</p>
<table border="0">
<tbody>
<tr>
<td bgcolor="#cccccc">
<pre>1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.</pre>
</td>
<td bgcolor="#cccccc">
<pre>&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;Loans&lt;/title&gt;
 &lt;/head&gt; 

 &lt;body&gt; 

 &lt;?php 

 $interest_rate = .14; 

 function YouOweMe($cost, $interest_rate) { 

 $weekly_payment = ($cost*$interest_rate); 

 print "You better pay me \$$weekly_payment every week, or else!"; 

 } 

&lt;font color="#000000"&gt;YouOweMe($cost, $interest_rate); 

 ?&gt; 

 &lt;/body&gt;
 &lt;/html&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>Here&#8217;s the line-by-line breakdown.</p>
<p>line 8: start php;<br />
line 10: set variable called $interest_rate to 14%;<br />
line 12: create function YouOweMe that relates to the variables $cost and $interest_rate;<br />
line 14: create variable $weekly_payment, the value of which is the cost times the interest rate;<br />
line 16: print to screen a sentence that uses the value of the $weekly_payment variable;<br />
line 20: engage the function YouOweMe, which (because of the function defined beforehand) simply prints the sentence <tt>You better pay me [14% of the amount the user entered on the form page] every week, or else!</tt></p>
<p>Notice on line 16 that we want the code to actually print out a dollar sign before the weekly payment. We escape that character with a \ to make sure the PHP engine doesn&#8217;t think we&#8217;re naming a variable there. Then we just happen to name a variable right afterwards ($WeeklyPayment), so the two together look like <tt> font size="2"&gt;\$$WeeklyPayment</tt>.</p>
<p><a name="Some_Final_Thoughts"></a></p>
<h3>Some Final Thoughts</h3>
<p>If it got a little brutal back there trying to make sense of my functions, don&#8217;t worry &#8212; you&#8217;ll probably get used to squinting through other people&#8217;s code once you get going. That&#8217;s because somebody has probably written code for whatever you need to do already, and is probably happy to share it with you. Making sense of it all gets easier and easier the more you use this stuff. And since PHP is an open-source language (meaning the source code is shared openly instead of being hoarded by an evil corporation), the language is surrounded by a sense of cooperation among its users, many of whom will help you if they can.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uttammitra.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uttammitra.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uttammitra.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uttammitra.wordpress.com&amp;blog=6154523&amp;post=17&amp;subd=uttammitra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uttammitra.wordpress.com/2009/10/23/php-basic-tutorials/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ffc0e392a0ef6da75867690d3985f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uttammitra</media:title>
		</media:content>

		<media:content url="http://www.wired.com/wired/webmonkey/stuff/PHP_Tutorial_utterance.gif" medium="image">
			<media:title type="html">PHP_Tutorial_utterance.gif</media:title>
		</media:content>
	</item>
	</channel>
</rss>
