Difference between revisions of "Designing Output Templates"

From ActionApps Documentation
Jump to: navigation, search
Line 8: Line 8:
  
 
== Where can the design come from ==
 
== Where can the design come from ==
<aafaq id=1714> ~ToDo: 1714 Where is the HTML</aafaq>
+
<div class="aafaq" id="faq1714"><aafaq id=1714> ~ToDo: id=1714 Where is the HTML </aafaq>
 +
==== FAQ: Where is the HTML ====
 +
 
 +
<br />The HTML for a typical APC-AA site can come from many places which can confuse
 +
people used to doing all their HTML in a single place.
 +
<table width="95%" border="1" cellspacing="1" cellpadding="1">
 +
<tr>
 +
<td><b>Location</b></td>
 +
<td><b>What to put there</b></td>
 +
</tr>
 +
<tr>
 +
<td><b>.</b>shtml file</td>
 +
<td> static HTML that doesn't repeat, and is not changed often. Can be edited
 +
with any standard web editor by someone who has write permissions on the
 +
web server. The HTML has lines like <!--#include "/apc-aa/view.php3
 +
--> (or apc-aa/slice.php3) to include a PHP file which will fetch information from the Slice's design.</td>
 +
</tr>
 +
<tr>
 +
<td>Design section of the Slice</td>
 +
<td>This is used to list a range of items in a slice, or display a single
 +
item. Someone with Admin permission on the slice can go to apc-aa/admin
 +
-> Admin -> Views or apc-aa/admin -> Admin -> Display/Index
 +
or Display/Fulltext. HTML can be placed here associated with the top and
 +
bottom of a listing, with each item, and with groupings of items. The HTML
 +
includes alias such as _#HEADLINE</td>
 +
</tr>
 +
<tr>
 +
<td>Aliases such as _#HEADLINE</td>
 +
<td>Each alias defines how to show a particular field, it does this by choosing
 +
a function (e.g. f_h) and parameters. For example _#HEADLINE is usually
 +
just output, while a Link might be output surrounded by <a href="
 +
and ">. They can be edited by anyone with administrator priviliges
 +
on your slice by going to Admin->Fields->choose field ->Edit. A
 +
field can have several different ways of being output, for example a date
 +
could have aliases for both short (1/1/200) and long (1 January 2000) forms
 +
of output.</td>
 +
</tr>
 +
<tr>
 +
<td>Functions such as f_h</td>
 +
<td>These define functions certain common ways fields are output. They are
 +
defined in the PHP code, and so have to be edited by developers, except
 +
that there is an extension function f_u that calls functions from apc-aa/include/usr_aliasfnc.php3,
 +
these can be written by anyone who understands PHP3.</td>
 +
</tr>
 +
<tr>
 +
<td>Data</td>
 +
<td>Lastly of course, the HTML could be in specific fields in your data. </td>
 +
</tr>
 +
</table>
 +
<br />Exceptions:
 +
<ul>
 +
<li>You don't have to put a .shtml at the top - you can just use a more complex
 +
URL refering to apc-aa/slice.php3 or apc-aa/view.php3</li>
 +
<li>You can include a view from within an alias by using the function f_v</li>
 +
</ul>
 +
 
 +
 
 +
</div>
  
  
 
== Special views (Calendar,RSS,..) ==
 
== Special views (Calendar,RSS,..) ==
<aafaq id=1745> ~ToDo: 1745 What are Views good for? </aafaq>  
+
<div class="aafaq" id="faq1745"><aafaq id=1745> ~ToDo: id=1745 What are Views good for? </aafaq>
<aafaq id=1743> ~ToDo: 1743 How do I include this View in a HTML page? </aafaq>
+
==== FAQ: What are Views good for? ====
<aafaq id=1677> ~ToDo: 1677 How do I sort items within a View? </aafaq>
+
 
<aafaq id=1676> ~ToDo: 1676 How do I select a sub-set of items from a view </aafaq>
+
 
<aafaq id=1678> ~ToDo: 1678 How do I create a Index of some items </aafaq>  
+
<br />Views are useful when you want functionality a little bit different from the
<aafaq id=1741> ~ToDo: 1741 How do I make it view just a single item? </aafaq>  
+
standard Index, or Full-Text views. You can use them to customize <a href="http://actionapps.org/faq/detail.shtml?x=1677">sorting</a>,
<aafaq id=1740> ~ToDo: 1740 How do I link a Index view to show the items in a Full Text view </aafaq>  
+
or pick <a href="http://actionapps.org/faq/detail.shtml?x=1741">certain items</a> or only a <a href="http://actionapps.org/faq/detail.shtml?x=1676">subset
<aafaq id=1737> ~ToDo: 1737 How can I change a piece of content on a page, for example a context-dependent Navigation menu </aafaq>  
+
of the items</a>.
<aafaq id=1738> ~ToDo: 1738 How can I parameterize a view and fill in details from the URL </aafaq>  
+
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1743"><aafaq id=1743> ~ToDo: id=1743 How do I include this View in a HTML page? </aafaq>
 +
==== FAQ: How do I include this View in a HTML page? ====
 +
 
 +
<p class="code"><!--#include virtual="/aa/view.php3?vid=5"-->
 +
 
 +
<br />Will embed view number 5 into your page. The view knows which slice it applies
 +
to, so this can be embedded in an Index or Full Text View.
 +
<br />View.php3 will take parameters either in the "include" line, or in
 +
the URL of the page to which it refers.
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1677"><aafaq id=1677> ~ToDo: id=1677 How do I sort items within a View? </aafaq>
 +
==== FAQ: How do I sort items within a View? ====
 +
 
 +
<br />You can sort items by specifying in the definition of the view (Admin->Views
 +
then select an existing View or click New) which fields to sort by, and wether
 +
to sort ascending or descending. The primary sort is the main ordering, and
 +
the secondary sorts within this. So for example you might specify Category as
 +
the primary sort, and sub-category as the secondary.<b> Note that if you sort
 +
on a field then there is a bug (or feature) where items without that field defined
 +
will not show up in the index view.</b>
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1676"><aafaq id=1676> ~ToDo: id=1676 How do I select a sub-set of items from a view </aafaq>
 +
==== FAQ: How do I select a sub-set of items from a view ====
 +
 
 +
<br />To select just a sub-set of the items, specify a Condition, or set of conditions,
 +
you can then parameterise that in the include statement or URL. So for example,
 +
if you set Condition 1 to "Category" and "LIKE" then you
 +
can specify a parameter of "cmd[5]=c-1-News" to set the first condition
 +
on View 5 to "News" so that it would list any item with a category
 +
containing the string "News". This condition could be set in either
 +
the Include statement or the URL e.g.
 +
<p class="code"><!--#include virtual="/aa/view.php3?vid=5&cmd[5]=c-1-News"-->
 +
 
 +
<br />or in the URL.
 +
<p class="code">?cmd[5]=c-1-News&.....
 +
<br />If there are special characters in the search term, i.e. dashes (as in E-mail)
 +
or spaces then quote it, and escape the quotes, for example to select a category=Social
 +
Ecology would require a URL of the form:
 +
<p class="code">conds[0][category........]=%22Social%20Ecology%22
 +
<br />
 +
<br />(%22 is a double quote (") and %20 is space). If you are constructing
 +
this URL from somewhere else and do not know what could be in the field then
 +
make sure to quote and urlencode the string.
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1678"><aafaq id=1678> ~ToDo: id=1678 How do I create a Index of some items </aafaq>
 +
==== FAQ: How do I create a Index of some items ====
 +
 
 +
<br />You have to be the slice administrator, then from the standard admin page select
 +
Admin -> Views, then you select "Item Listing" and click New.
 +
<br />The first few items are the same as for creating Index views <b>(see the manual)</b>.
 +
You can then specify <b>how to sort items</b>, and <b>specify a condition (that
 +
can take a parameter in the URL)</b>.
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1741"><aafaq id=1741> ~ToDo: id=1741 How do I make it view just a single item? rel:2090,1740,1736,</aafaq>
 +
==== FAQ: How do I make it view just a single item? ====
 +
 
 +
<br />Create a Full-Text view by going to Admin->Views and selecting "Full
 +
Text" and clicking "New". Then you can specify cmd[5]=i-5-1a2b3c4d
 +
in the URL or include statement. You can also use cmd[5]=x-5-934 where 934 is short _id
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1740"><aafaq id=1740> ~ToDo: id=1740 How do I link a Index view to show the items in a Full Text view rel:1741</aafaq>
 +
==== FAQ: How do I link a Index view to show the items in a Full Text view ====
 +
 
 +
<br />The right alias is _#ITEM_ID#.
 +
<br />For example, to show an item in a full text view, the view.php3 script should
 +
get the parameters like:
 +
<p class="code">vid=110&cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf
 +
<br />( the 'i' command to view.php3 script takes as argument unpacked (long) item
 +
id)<br>
 +
 
 +
<br />So if we pass the vid parameter directly in fulltext.shtml page:<br>
 +
fulltext.shtml:
 +
<p class="code"><!--#include virtual="/aaa/view.php3?vid=110"-->
 +
<br />Which then needs us to pass the cmd parameter through url:
 +
<p class="code"><a href="fulltext.shtml?cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf">
 +
fulltext </a>
 +
<br />So we can generate this by placing in the Odd rows field of an index view
 +
<br /><a href="fulltext.shtml?cmd[110]=i-110-_#ITEM_ID#"> fulltext
 +
</a><br>
 +
 
 +
<br />If you want to link to a view appearing in the same place on the same page (as for the main index going to a full text), then if your Index view has vid=109 then the URL should be:<p class="code">"?cmd[109]=i-110-_#ITEM_ID#"
 +
<br />which will redraw the same screen, replacing view 109 with view110, for the item specified.
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1737"><aafaq id=1737> ~ToDo: id=1737 How can I change a piece of content on a page, for example a context-dependent Navigation menu </aafaq>
 +
==== FAQ: How can I change a piece of content on a page, for example a context-dependent Navigation menu ====
 +
 
 +
<br />
 +
Views can be swapped in and out from the URL, using syntax like "cmd[5]=v-8"
 +
to display view 8 at the place where View 5 was expected (for example by <!--#include="/aa/view.php3?vid=5"-->
 +
<br />For example, if you want a navigation menu that redraws itself depending on
 +
what is clicked on, you should create each of the different views you want to
 +
appear and then include one view in the shtml page. Then you can switch between
 +
displayed views using the url parameter.<br>
 +
 
 +
<br />For Example: <br>
 +
----------- index.shtml ----------<br>
 +
<span class="code">[...]<br>
 +
<h3>content</h3><br>
 +
<!--#include virtual="/apc-aa/view.php3?vid=9"--><br>
 +
<p> page footer... </p><br>
 +
[...]</span>
 +
<br /><br>
 +
--------- code for this menu in the Odd row field of view #9-----<br>
 +
<span class="code">[...]<br>
 +
<a href="index.shtml?cmd[9]=v-13">News</a><br><br>
 +
<a href="index.shtml?cmd[9]=v-14">Calendar</a><br><br>
 +
<a href="index.shtml?cmd[9]=v-15">About us</a><br><br>
 +
[...]</span><br>
 +
 
 +
<br />When the index.shtml page is redrawn the initial view #9 will be replaced by
 +
the appropriate view, for example view #13 will appear in the News slice and
 +
view #14 in the Calendar slice.
 +
<br />Because the PHP is interpreted via an include on the server, you cannot easily
 +
change the view at run-time, for example changing it based on a mouse-over event,
 +
it requires a page to be redrawn.
 +
 
 +
 
 +
 
 +
</div>
 +
<div class="aafaq" id="faq1738"><aafaq id=1738> ~ToDo: id=1738 How can I parameterize a view and fill in details from the URL rel:1741</aafaq>
 +
==== FAQ: How can I parameterize a view and fill in details from the URL ====
 +
 
 +
 
 +
<br />You can use aliases defined in the URL parameter 'als'. For a detailed description
 +
of the als parameter, see "<a href="http://actionapps.org/faq/detail.shtml?x=1767">What parameters can I
 +
use with slice.php3</a>"
 +
<br />For example,
 +
<br />There are 13 navigation pages. For example, there is a page on 'Communication
 +
Rights' which has a report on Internet Rights in general and links to the pages
 +
<br />
 +
'Communication Rights in South Africa'<br />
 +
'Communication Rights in Morocco'<br />
 +
'Communication Rights in Senegal'<br />
 +
etc...
 +
<br />I did not want to write 13 pages, so I used 2 static views -- one for country
 +
pages, and one for topic pages.
 +
<br />The topic page is /topic.shtml. It has this include
 +
<p class="code"><!--#include virtual="/apc-aa/view.php3?vid=2-->
 +
<br />topic.shtml will be called with parameters. To create the 'Communication Rights'
 +
topic page, it will be called as
 +
<p class="code">/topic.shtml?als[MY_TOPIC]=Communication+Rights&als[URLE_TOP]=Communication%2BRights
 +
<br />URLE_TOP is an alias similar to MY_TOPIC, but it double URL encodes the value.
 +
It will be used to generate links. %2B represents the +. A + in url encoding
 +
is a space.
 +
<br />In this topic.shtml I want to create links to these pages. To create these
 +
links, view #2 has this 'odd row' format:
 +
<p class="code"><a href="/resource.shtml?cmd[1]=c-1-South%2BAfrica-c-2-_#URLE_TOP">South
 +
Africa - _#MY_TOPIC </a><br />
 +
<a href="/resource.shtml?cmd[1]=c-1-Morocco-c-2-_#URLE_TOP">Morocco
 +
- _#MY_TOPIC </a><br />
 +
<a href="/resource.shtml?cmd[1]=c-1-Senegal-c-2-_#URLE_TOP">Senegal
 +
- _#MY_TOPIC </a>
 +
<br />and the MY_TOPIC and URLE_TOP are substituted from the als parameters in the
 +
URL. <br />
 +
 
 +
 
 +
 
 +
</div>
  
  
 
== Index View  vs. Other Views  ==
 
== Index View  vs. Other Views  ==
<aafaq id=1699> ~ToDo: 1699 Which should I use, Item Listing View (View.php3) or Design-Index (slice.php3)? </aafaq>  
+
<div class="aafaq" id="faq1699"><aafaq id=1699> ~ToDo: id=1699 Which should I use, Item Listing View (View.php3) or Design-Index (slice.php3)? </aafaq>
 +
==== FAQ: Which should I use, Item Listing View (View.php3) or Design-Index (slice.php3)? ====
 +
 
 +
 
 +
<br />The Item Listing View (View.php3) and Design-Index (slice.php3) provide overlapping features. Which to use will depend on which features you need. Here are some of the differences.
 +
<table border="1"><tbody><tr><td><b>Available features</b></td><td><b>View</b></td><td><b>Index</b></td></tr>
 +
<tr><td>Search conditions from URL</td><td><a href="http://actionapps.org/faq/detail.shtml?x=1676">Yes</a></td><td><a href="http://actionapps.org/faq/detail.shtml?x=1767">Yes</a></td></tr>
 +
<tr><td>Search Form</td><td>No</td><td><#215>Yes</td></tr>
 +
<tr><td>?x=1699</td><td>No <a href="http://actionapps.org/faq/detail.shtml?x=1740"> (workaround)</a></td><td>Yes</td></tr>
 +
<tr><td>Scroller</td><td>No</td><td>Yes</td></tr>
 +
<tr><td>Slice id</td><td>Implicit, can be overridden by parameter</td><td>Parameter in include or URL</td></tr>
 +
<tr><td>Copy with Template</td><td>Yes with new wizard, but may need to edit HTML because numbers change</td><td>Yes</td></tr>
 +
<tr><td>Sorting</td><td><a href="http://actionapps.org/faq/detail.shtml?x=1677">From Admin only</a></td><td>From <a href="http://actionapps.org/faq/detail.shtml?x=1767">URL parameters</a> only</td></tr>
 +
</tbody></table>
 +
 
 +
 
 +
 
 +
 
 +
</div>
  
 
== Empty result set ==
 
== Empty result set ==
<aafaq id=1658> ~ToDo: 1658 How "No item found" message in view definition works? </aafaq>
+
<div class="aafaq" id="faq1658"><aafaq id=1658> ~ToDo: id=1658 How "No item found" message in view definition works? rel:277,</aafaq>
 +
==== FAQ: How "No item found" message in view definition works? ====
 +
 
 +
In view you can specify "No item found" message, which is displayed if
 +
view (due to its current conditions) do not find an item to display.You can
 +
enter there:<br>
 +
<UL>
 +
<li><i>nothing</i> - standard "no
 +
item found" message is displayed (this setting is historical)
 +
 
 +
<li><i>any text</i> - the text is
 +
displayed. From AA v2.6 you can also use aliases and other AA expressions like
 +
{switch()...}...
 +
 
 +
<li><--Vacuum--> - if you use this keyword (exactly!), nothing is displayed.</li></UL>
 +
<P>One recomendation is to write something that relates to the slice content,
 +
e.g. "No news found" or "No events found", with in visible HTML or a comment
 +
tag. This helps with both usability and view development problem
 +
solving.</P>
 +
 
 +
 
 +
</div>

Revision as of 00:02, 25 August 2005

Let's assume we have some data in the ActionApps slice. In this chapter, we'll look at how to present the data on the website, that means how to create a (single) web page which lists the data in the desired format and look. First, let's look briefly at which parts of ActionApps are responsible for generating the design:

Index View

~ToDo: Describe index view

Fultext View

~ToDo: Describe fulltext view 

Where can the design come from

Where is the HTML

The HTML for a typical APC-AA site can come from many places which can confuse people used to doing all their HTML in a single place.

Location What to put there
.shtml file static HTML that doesn't repeat, and is not changed often. Can be edited with any standard web editor by someone who has write permissions on the web server. The HTML has lines like <!--#include "/apc-aa/view.php3 --> (or apc-aa/slice.php3) to include a PHP file which will fetch information from the Slice's design.
Design section of the Slice This is used to list a range of items in a slice, or display a single item. Someone with Admin permission on the slice can go to apc-aa/admin -> Admin -> Views or apc-aa/admin -> Admin -> Display/Index or Display/Fulltext. HTML can be placed here associated with the top and bottom of a listing, with each item, and with groupings of items. The HTML includes alias such as _#HEADLINE
Aliases such as _#HEADLINE Each alias defines how to show a particular field, it does this by choosing a function (e.g. f_h) and parameters. For example _#HEADLINE is usually just output, while a Link might be output surrounded by <a href=" and ">. They can be edited by anyone with administrator priviliges on your slice by going to Admin->Fields->choose field ->Edit. A field can have several different ways of being output, for example a date could have aliases for both short (1/1/200) and long (1 January 2000) forms of output.
Functions such as f_h These define functions certain common ways fields are output. They are defined in the PHP code, and so have to be edited by developers, except that there is an extension function f_u that calls functions from apc-aa/include/usr_aliasfnc.php3, these can be written by anyone who understands PHP3.
Data Lastly of course, the HTML could be in specific fields in your data.

Exceptions:

  • You don't have to put a .shtml at the top - you can just use a more complex URL refering to apc-aa/slice.php3 or apc-aa/view.php3
  • You can include a view from within an alias by using the function f_v


FAQ: Where is the HTML


The HTML for a typical APC-AA site can come from many places which can confuse people used to doing all their HTML in a single place.

Location What to put there
.shtml file static HTML that doesn't repeat, and is not changed often. Can be edited

with any standard web editor by someone who has write permissions on the

web server. The HTML has lines like (or apc-aa/slice.php3) to include a PHP file which will fetch information from the Slice's design.
Design section of the Slice This is used to list a range of items in a slice, or display a single

item. Someone with Admin permission on the slice can go to apc-aa/admin -> Admin -> Views or apc-aa/admin -> Admin -> Display/Index or Display/Fulltext. HTML can be placed here associated with the top and bottom of a listing, with each item, and with groupings of items. The HTML

includes alias such as _#HEADLINE
Aliases such as _#HEADLINE Each alias defines how to show a particular field, it does this by choosing

a function (e.g. f_h) and parameters. For example _#HEADLINE is usually just output, while a Link might be output surrounded by <a href=" and ">. They can be edited by anyone with administrator priviliges on your slice by going to Admin->Fields->choose field ->Edit. A field can have several different ways of being output, for example a date could have aliases for both short (1/1/200) and long (1 January 2000) forms

of output.
Functions such as f_h These define functions certain common ways fields are output. They are

defined in the PHP code, and so have to be edited by developers, except that there is an extension function f_u that calls functions from apc-aa/include/usr_aliasfnc.php3,

these can be written by anyone who understands PHP3.
Data Lastly of course, the HTML could be in specific fields in your data.


Exceptions:

  • You don't have to put a .shtml at the top - you can just use a more complex URL refering to apc-aa/slice.php3 or apc-aa/view.php3
  • You can include a view from within an alias by using the function f_v



Special views (Calendar,RSS,..)

What are Views good for?

Views are useful when you want functionality a little bit different from the standard Index, or Full-Text views. You can use them to customize sorting, or pick certain items or only a subset of the items.


FAQ: What are Views good for?


Views are useful when you want functionality a little bit different from the standard Index, or Full-Text views. You can use them to customize <a href="http://actionapps.org/faq/detail.shtml?x=1677">sorting</a>, or pick <a href="http://actionapps.org/faq/detail.shtml?x=1741">certain items</a> or only a <a href="http://actionapps.org/faq/detail.shtml?x=1676">subset of the items</a>.


How do I include this View in a HTML page?

<!--#include virtual="/aa/view.php3?vid=5"-->

Will embed view number 5 into your page. The view knows which slice it applies to, so this can be embedded in an Index or Full Text View.

View.php3 will take parameters either in the "include" line, or in the URL of the page to which it refers.


FAQ: How do I include this View in a HTML page?


Will embed view number 5 into your page. The view knows which slice it applies to, so this can be embedded in an Index or Full Text View.
View.php3 will take parameters either in the "include" line, or in the URL of the page to which it refers. </div>

How do I sort items within a View?

You can sort items by specifying in the definition of the view (Admin->Views then select an existing View or click New) which fields to sort by, and wether to sort ascending or descending. The primary sort is the main ordering, and the secondary sorts within this. So for example you might specify Category as the primary sort, and sub-category as the secondary. Note that if you sort on a field then there is a bug (or feature) where items without that field defined will not show up in the index view.


FAQ: How do I sort items within a View?


You can sort items by specifying in the definition of the view (Admin->Views then select an existing View or click New) which fields to sort by, and wether to sort ascending or descending. The primary sort is the main ordering, and the secondary sorts within this. So for example you might specify Category as the primary sort, and sub-category as the secondary. Note that if you sort on a field then there is a bug (or feature) where items without that field defined will not show up in the index view.


How do I select a sub-set of items from a view

To select just a sub-set of the items, specify a Condition, or set of conditions, you can then parameterise that in the include statement or URL. So for example, if you set Condition 1 to "Category" and "LIKE" then you can specify a parameter of "cmd[5]=c-1-News" to set the first condition on View 5 to "News" so that it would list any item with a category containing the string "News". This condition could be set in either the Include statement or the URL e.g.

<!--#include virtual="/aa/view.php3?vid=5&cmd[5]=c-1-News"-->

or in the URL.

?cmd[5]=c-1-News&.....

If there are special characters in the search term, i.e. dashes (as in E-mail) or spaces then quote it, and escape the quotes, for example to select a category=Social Ecology would require a URL of the form:

conds[0][category........]=%22Social%20Ecology%22

(%22 is a double quote (") and %20 is space). If you are constructing this URL from somewhere else and do not know what could be in the field then make sure to quote and urlencode the string.


FAQ: How do I select a sub-set of items from a view


To select just a sub-set of the items, specify a Condition, or set of conditions, you can then parameterise that in the include statement or URL. So for example, if you set Condition 1 to "Category" and "LIKE" then you can specify a parameter of "cmd[5]=c-1-News" to set the first condition on View 5 to "News" so that it would list any item with a category containing the string "News". This condition could be set in either the Include statement or the URL e.g. <p class="code">


or in the URL. <p class="code">?cmd[5]=c-1-News&.....
If there are special characters in the search term, i.e. dashes (as in E-mail) or spaces then quote it, and escape the quotes, for example to select a category=Social Ecology would require a URL of the form: <p class="code">conds[0][category........]=%22Social%20Ecology%22

(%22 is a double quote (") and %20 is space). If you are constructing this URL from somewhere else and do not know what could be in the field then make sure to quote and urlencode the string.


How do I create a Index of some items

You have to be the slice administrator, then from the standard admin page select Admin -> Views, then you select "Item Listing" and click New.

The first few items are the same as for creating Index views (see the manual). You can then specify how to sort items, and specify a condition (that can take a parameter in the URL).


FAQ: How do I create a Index of some items


You have to be the slice administrator, then from the standard admin page select Admin -> Views, then you select "Item Listing" and click New.
The first few items are the same as for creating Index views (see the manual). You can then specify how to sort items, and specify a condition (that can take a parameter in the URL).


How do I make it view just a single item?

Create a Full-Text view by going to Admin->Views and selecting "Full Text" and clicking "New". Then you can specify cmd[5]=i-5-1a2b3c4d in the URL or include statement. You can also use cmd[5]=x-5-934 where 934 is short _id


FAQ: How do I make it view just a single item?


Create a Full-Text view by going to Admin->Views and selecting "Full Text" and clicking "New". Then you can specify cmd[5]=i-5-1a2b3c4d in the URL or include statement. You can also use cmd[5]=x-5-934 where 934 is short _id


How do I link a Index view to show the items in a Full Text view

The right alias is _#ITEM_ID#.

For example, to show an item in a full text view, the view.php3 script should get the parameters like:

vid=110&cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf

( the 'i' command to view.php3 script takes as argument unpacked (long) item id)

So if we pass the vid parameter directly in fulltext.shtml page:
fulltext.shtml:

<!--#include virtual="/aaa/view.php3?vid=110"-->

Which then needs us to pass the cmd parameter through url:

<a href="fulltext.shtml?cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf"> fulltext </a>

So we can generate this by placing in the Odd rows field of an index view

<a href="fulltext.shtml?cmd[110]=i-110-_#ITEM_ID#"> fulltext </a>

If you want to link to a view appearing in the same place on the same page (as for the main index going to a full text), then if your Index view has vid=109 then the URL should be:

"?cmd[109]=i-110-_#ITEM_ID#"

which will redraw the same screen, replacing view 109 with view110, for the item specified.


FAQ: How do I link a Index view to show the items in a Full Text view


The right alias is _#ITEM_ID#.
For example, to show an item in a full text view, the view.php3 script should get the parameters like: <p class="code">vid=110&cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf
( the 'i' command to view.php3 script takes as argument unpacked (long) item id)


So if we pass the vid parameter directly in fulltext.shtml page:
fulltext.shtml: <p class="code">
Which then needs us to pass the cmd parameter through url: <p class="code"><a href="fulltext.shtml?cmd[110]=i-110-2548e4b7ae7b8874ee4a4bf"> fulltext </a>
So we can generate this by placing in the Odd rows field of an index view
<a href="fulltext.shtml?cmd[110]=i-110-_#ITEM_ID#"> fulltext </a>


If you want to link to a view appearing in the same place on the same page (as for the main index going to a full text), then if your Index view has vid=109 then the URL should be:<p class="code">"?cmd[109]=i-110-_#ITEM_ID#"
which will redraw the same screen, replacing view 109 with view110, for the item specified.


How can I change a piece of content on a page, for example a context-dependent Navigation menu

Views can be swapped in and out from the URL, using syntax like "cmd[5]=v-8" to display view 8 at the place where View 5 was expected (for example by <!--#include="/aa/view.php3?vid=5"-->

For example, if you want a navigation menu that redraws itself depending on what is clicked on, you should create each of the different views you want to appear and then include one view in the shtml page. Then you can switch between displayed views using the url parameter.

For Example:
----------- index.shtml ----------
[...]
<h3>content</h3>
<!--#include virtual="/apc-aa/view.php3?vid=9"-->
<p> page footer... </p>
[...]


--------- code for this menu in the Odd row field of view #9-----
[...]
<a href="index.shtml?cmd[9]=v-13">News</a><br>
<a href="index.shtml?cmd[9]=v-14">Calendar</a><br>
<a href="index.shtml?cmd[9]=v-15">About us</a><br>
[...]

When the index.shtml page is redrawn the initial view #9 will be replaced by the appropriate view, for example view #13 will appear in the News slice and view #14 in the Calendar slice.

Because the PHP is interpreted via an include on the server, you cannot easily change the view at run-time, for example changing it based on a mouse-over event, it requires a page to be redrawn.


FAQ: How can I change a piece of content on a page, for example a context-dependent Navigation menu


Views can be swapped in and out from the URL, using syntax like "cmd[5]=v-8" to display view 8 at the place where View 5 was expected (for example by
For example, if you want a navigation menu that redraws itself depending on what is clicked on, you should create each of the different views you want to appear and then include one view in the shtml page. Then you can switch between displayed views using the url parameter.


For Example:


index.shtml ----------

[...]

content



<p> page footer... </p>
[...]


code for this menu in the Odd row field of view #9-----

[...]
<a href="index.shtml?cmd[9]=v-13">News</a>

<a href="index.shtml?cmd[9]=v-14">Calendar</a>

<a href="index.shtml?cmd[9]=v-15">About us</a>

[...]


When the index.shtml page is redrawn the initial view #9 will be replaced by the appropriate view, for example view #13 will appear in the News slice and view #14 in the Calendar slice.
Because the PHP is interpreted via an include on the server, you cannot easily change the view at run-time, for example changing it based on a mouse-over event, it requires a page to be redrawn.


How can I parameterize a view and fill in details from the URL

You can use aliases defined in the URL parameter 'als'. For a detailed description of the als parameter, see "What parameters can I use with slice.php3"

For example,

There are 13 navigation pages. For example, there is a page on 'Communication Rights' which has a report on Internet Rights in general and links to the pages
'Communication Rights in South Africa'
'Communication Rights in Morocco'
'Communication Rights in Senegal'
etc...

I did not want to write 13 pages, so I used 2 static views -- one for country pages, and one for topic pages.

The topic page is /topic.shtml. It has this include

<!--#include virtual="/apc-aa/view.php3?vid=2-->

topic.shtml will be called with parameters. To create the 'Communication Rights' topic page, it will be called as

/topic.shtml?als[MY_TOPIC]=Communication+Rights&als[URLE_TOP]=Communication%2BRights

URLE_TOP is an alias similar to MY_TOPIC, but it double URL encodes the value. It will be used to generate links. %2B represents the +. A + in url encoding is a space.

In this topic.shtml I want to create links to these pages. To create these links, view #2 has this 'odd row' format:

<a href="/resource.shtml?cmd[1]=c-1-South%2BAfrica-c-2-_#URLE_TOP">South Africa - _#MY_TOPIC </a>
<a href="/resource.shtml?cmd[1]=c-1-Morocco-c-2-_#URLE_TOP">Morocco - _#MY_TOPIC </a>
<a href="/resource.shtml?cmd[1]=c-1-Senegal-c-2-_#URLE_TOP">Senegal - _#MY_TOPIC </a>

and the MY_TOPIC and URLE_TOP are substituted from the als parameters in the URL.


FAQ: How can I parameterize a view and fill in details from the URL


You can use aliases defined in the URL parameter 'als'. For a detailed description of the als parameter, see "<a href="http://actionapps.org/faq/detail.shtml?x=1767">What parameters can I use with slice.php3</a>"
For example,
There are 13 navigation pages. For example, there is a page on 'Communication Rights' which has a report on Internet Rights in general and links to the pages
'Communication Rights in South Africa'
'Communication Rights in Morocco'
'Communication Rights in Senegal'
etc...
I did not want to write 13 pages, so I used 2 static views -- one for country pages, and one for topic pages.
The topic page is /topic.shtml. It has this include <p class="code">
topic.shtml will be called with parameters. To create the 'Communication Rights' topic page, it will be called as <p class="code">/topic.shtml?als[MY_TOPIC]=Communication+Rights&als[URLE_TOP]=Communication%2BRights
URLE_TOP is an alias similar to MY_TOPIC, but it double URL encodes the value. It will be used to generate links. %2B represents the +. A + in url encoding is a space.
In this topic.shtml I want to create links to these pages. To create these links, view #2 has this 'odd row' format: <p class="code"><a href="/resource.shtml?cmd[1]=c-1-South%2BAfrica-c-2-_#URLE_TOP">South Africa - _#MY_TOPIC </a>
<a href="/resource.shtml?cmd[1]=c-1-Morocco-c-2-_#URLE_TOP">Morocco - _#MY_TOPIC </a>
<a href="/resource.shtml?cmd[1]=c-1-Senegal-c-2-_#URLE_TOP">Senegal - _#MY_TOPIC </a>
and the MY_TOPIC and URLE_TOP are substituted from the als parameters in the URL.



Index View vs. Other Views

Which should I use, Item Listing View (View.php3) or Design-Index (slice.php3)?

The Item Listing View (View.php3) and Design-Index (slice.php3) provide overlapping features. Which to use will depend on which features you need. Here are some of the differences.

Available featuresViewIndex
Search conditions from URLYesYes
Search FormNo<#215>Yes
?x=1699No (workaround)Yes
ScrollerNoYes
Slice idImplicit, can be overridden by parameterParameter in include or URL
Copy with TemplateYes with new wizard, but may need to edit HTML because numbers changeYes
SortingFrom Admin onlyFrom URL parameters only


FAQ: Which should I use, Item Listing View (View.php3) or Design-Index (slice.php3)?


The Item Listing View (View.php3) and Design-Index (slice.php3) provide overlapping features. Which to use will depend on which features you need. Here are some of the differences.

<tbody> </tbody>
Available featuresViewIndex
Search conditions from URL<a href="http://actionapps.org/faq/detail.shtml?x=1676">Yes</a><a href="http://actionapps.org/faq/detail.shtml?x=1767">Yes</a>
Search FormNo<#215>Yes
?x=1699No <a href="http://actionapps.org/faq/detail.shtml?x=1740"> (workaround)</a>Yes
ScrollerNoYes
Slice idImplicit, can be overridden by parameterParameter in include or URL
Copy with TemplateYes with new wizard, but may need to edit HTML because numbers changeYes
Sorting<a href="http://actionapps.org/faq/detail.shtml?x=1677">From Admin only</a>From <a href="http://actionapps.org/faq/detail.shtml?x=1767">URL parameters</a> only



Empty result set

How "No item found" message in view definition works?

In view you can specify "No item found" message, which is displayed if view (due to its current conditions) do not find an item to display.You can enter there:

  • nothing - standard "no item found" message is displayed (this setting is historical)
  • any text - the text is displayed. From AA v2.6 you can also use aliases and other AA expressions like {switch()...}...
  • <--Vacuum--> - if you use this keyword (exactly!), nothing is displayed.

One recomendation is to write something that relates to the slice content, e.g. "No news found" or "No events found", with in visible HTML or a comment tag. This helps with both usability and view development problem solving.


FAQ: How "No item found" message in view definition works?

In view you can specify "No item found" message, which is displayed if view (due to its current conditions) do not find an item to display.You can enter there:

  • nothing - standard "no item found" message is displayed (this setting is historical)
  • any text - the text is displayed. From AA v2.6 you can also use aliases and other AA expressions like {switch()...}...
  • <--Vacuum--> - if you use this keyword (exactly!), nothing is displayed.

<P>One recomendation is to write something that relates to the slice content, e.g. "No news found" or "No events found", with in visible HTML or a comment tag. This helps with both usability and view development problem solving.</P>