Protoball:Essay Sort Order

From Protoball
Jump to navigation Jump to search

Introduction

We are adding a field to the Essay form and template; we are using that field to sort the list of Essays on the main page.

Parts of the Puzzle

The Template

Here is the template edit page: http://protoball.org/index.php?title=Template:Essay&action=edit.

You can also get there by clicking on the edit tab of the template page Template:Essay.

The template is used both to display the information and store it.

The Form

Here is the form edit page: http://protoball.org/index.php?title=Form:Essay&action=edit.

You can also get there by clicking on the edit tab of the form page Form:Essay.

The form is used to gather information for an essay.

An Essay Page, AKA Record

Each essay has its own page.

Example page: The_Evolution_of_the_Baseball_Up_To_1872

When you look at the edit page of this essay, you see some squiggly brackets holding information at the top. This is the combined action of the form working with the template.

I also call this page a record because the information is has acts like a row or record in a daabase table or spreadsheet.

The edit page of the example: http://protoball.org/index.php?title=The_Evolution_of_the_Baseball_Up_To_1872&action=edit

The Main Essays Page

Here is a link to the main Essays page edit page: http://protoball.org/index.php?title=Essays&action=edit

You can also get there by clicking on the edit tab of the essays page Essays.

This is the page that displays the list of Essays. This is where we change the list command to sort by our new field.

Making the Changes

Now that we know the pieces of the puzzle. Let's put them together.

Adding a Sort Order Field to the Template

We are adding a field to the template:

We are working on this page: http://protoball.org/index.php?title=Template:Essay&action=edit

We are editing two parts. Make both changes, then hit save.

Section 1

First section of template we are editing:

{{Essay
|Title=
|Description=
|Digger=
|Essay Date=
|Related Pages=
}}

This first part is used mainly for people like use to quickly grasp the fields in the template. I also use this to auto-generate the database we use for enhanced searches.


Result of editing, adding the Sort Order field:

First section:

{{Essay
|Title=
|Description=
|Digger=
|Essay Date=
|Related Pages=
|Sort Order=
}}

Section 2

Second section of the template we are editing:

</noinclude><includeonly>{{Essay Box}}{{Subtitle|[[Description::{{{Description|}}}]]}}
<div class="center">by {{#arraymap:{{{Digger|}}}|,|x|[[Digger::x]]}}, {{#time: F Y|{{{Essay Date}}}}}</div>
{{#if: {{{Related Pages|}}}|<div class="center">Related: {{#arraymap:{{{Related Pages|}}}|,|x|[[Related Pages::x]]}}</div>}}
{{#set:Title={{{Title}}}|Essay Date={{{Essay Date}}}}}

Second section of the template we are editing:

</noinclude><includeonly>{{Essay Box}}{{Subtitle|[[Description::{{{Description|}}}]]}}
<div class="center">by {{#arraymap:{{{Digger|}}}|,|x|[[Digger::x]]}}, {{#time: F Y|{{{Essay Date}}}}}</div>
{{#if: {{{Related Pages|}}}|<div class="center">Related: {{#arraymap:{{{Related Pages|}}}|,|x|[[Related Pages::x]]}}</div>}}
{{#set:Title={{{Title}}}|Essay Date={{{Essay Date}}}|Sort Order={{{Sort Order}}}}}

The sort order field assignment is added to the end.

OK. Hit save. We are done.

Adding a Sort Order Field to the Form

We are adding a field to the form:

We are working on this page: http://protoball.org/index.php?title=Form:Essay&action=edit

Section of the form we are editing:

|-
! Related Pages:
| {{{field|Related Pages}}}
|}
{{{end template}}}

The is the end of the fields offered in the form.

Result of the editing the section of the form:

|-
! Related Pages:
| {{{field|Related Pages}}}
|-
! Sort Order:
| {{{field|Sort Order|class=number}}}
|}
{{{end template}}}

Hit save.

Great! Now we are done adding the field. Let's use it.

Adding for the Sort Order to each Essay

We are going to each of the essays, editing them using the edit with form tab and entering a sort value.

The lowest sort value will end up at the top. You could use values in the 100s to make it easier to insert essays in between other essays later.

List of Essays

Changing the List to Sort by our new field

Our last step is to tell the essay page to sort by the Sort Order field.

Here is a link to the main Essays page edit page: http://protoball.org/index.php?title=Essays&action=edit

You can also get there by clicking on the edit tab of the essays page Essays.

The page before changes:

{{Essay Box}}
{{Subtitle|Essays by Diggers}}
{{#ask: [[Category:Essays]]
| ?Digger
| ?Description
| ?Essay Date
| format=template
| template=Display Essay
| sort=Essay Date
| limit=1000
}}

The page after changes:

{{Essay Box}}
{{Subtitle|Essays by Diggers}}
{{#ask: [[Category:Essays]]
| ?Digger
| ?Description
| ?Essay Date
| format=template
| template=Display Essay
| sort=Sort Order
| limit=1000
}}

We change the sort= line to use the Sort Order field

Hit Save.

Success!