Difference between revisions of "Week Thirteen (MGDP2060)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
Line 3: Line 3:
 
Previous: [[Week_Twelve_(MGDP2060)|Week Twelve]].
 
Previous: [[Week_Twelve_(MGDP2060)|Week Twelve]].
 
Next: [[Week_Fourteen_(MGDP2060)|Week Fourteen]].
 
Next: [[Week_Fourteen_(MGDP2060)|Week Fourteen]].
 +
 +
== WordPress:  the loop ==
 +
 +
WordPress has a concept known as the '''the loop'''.
 +
 +
It is so named because it "loops around and around".
 +
 +
Typically the loop is processing a [[recordset]], which consists of zero or more [[records]].
 +
 +
A record is a unit of data, for example a blog post.
 +
 +
A record typically has multiple [[Data field|data fields]].  For example, a blog post record typically has fields for Title, Date Posted, Author, Content, etc.
 +
 +
Use the loop to process a recordset, one record at a time.
 +
 +
1. Start at top of loop
 +
2. Display any HTML, and run any PHP code, inside the loop.
 +
2.1 Data in the loop pertains to one recordset at a time, in sequence:  first record, second record, etc.
 +
3. At the bottom of the loop, "loop back" to (1) until all records are processed.
 +
 +
You must stop the loop at some point.  If you don't stop the loop, you have an "endless loop", which is a Bad Thing.
 +
 +
Stopping the loop involves [[boolean logic]] (true or false).
 +
 +
The logic can take several different forms.  A typical example tests for data at the top of the loop:
 +
 +
* Is there a record to process?
 +
** If true, continue with HTML and PHP inside the loop
 +
** False, jump to the next line of code after the loop
 +
 +
== WordPress loop:  code sample #1 ==
 +
 +
A simple loop:
 +
 +
<pre>
 +
...
 +
</pre>
 +
 +
== Next week ==
 +
 +
Next week -- Week Fourteen -- is the second-to-last class session.
 +
 +
we will discuss domain names, domain name registration, managing domain names, and related topics.
 +
 +
See [[Week_Fourteen_(MGDP2060)|Week Fourteen]].
  
 
== See also ==
 
== See also ==
  
 
* [[Web Design and Development III (MGDP2060)]]
 
* [[Web Design and Development III (MGDP2060)]]

Revision as of 07:45, 3 December 2015

This article lists topics for Week Thirteen of Web Design and Development III (MGDP2060).

Previous: Week Twelve. Next: Week Fourteen.

WordPress: the loop

WordPress has a concept known as the the loop.

It is so named because it "loops around and around".

Typically the loop is processing a recordset, which consists of zero or more records.

A record is a unit of data, for example a blog post.

A record typically has multiple data fields. For example, a blog post record typically has fields for Title, Date Posted, Author, Content, etc.

Use the loop to process a recordset, one record at a time.

1. Start at top of loop 2. Display any HTML, and run any PHP code, inside the loop. 2.1 Data in the loop pertains to one recordset at a time, in sequence: first record, second record, etc. 3. At the bottom of the loop, "loop back" to (1) until all records are processed.

You must stop the loop at some point. If you don't stop the loop, you have an "endless loop", which is a Bad Thing.

Stopping the loop involves boolean logic (true or false).

The logic can take several different forms. A typical example tests for data at the top of the loop:

  • Is there a record to process?
    • If true, continue with HTML and PHP inside the loop
    • False, jump to the next line of code after the loop

WordPress loop: code sample #1

A simple loop:

...

Next week

Next week -- Week Fourteen -- is the second-to-last class session.

we will discuss domain names, domain name registration, managing domain names, and related topics.

See Week Fourteen.

See also