| 
									
										
										
										
											2004-04-13 08:46:28 +00:00
										 |  |  | <?xml version="1.0" encoding="iso-8859-1"?> | 
					
						
							|  |  |  | <!-- $Revision$ --> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  | <sect1 id="language.function.cycle"> | 
					
						
							| 
									
										
										
										
											2005-05-25 19:13:20 +00:00
										 |  |  |  <title>{cycle}</title> | 
					
						
							| 
									
										
										
										
											2005-09-13 19:03:11 +00:00
										 |  |  |   <para> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |    <varname>{cycle}</varname> is used to alternate a set of values. | 
					
						
							|  |  |  |    This makes it easy to for example, alternate between two or more colors | 
					
						
							|  |  |  |    in a table, or cycle through an array of values. | 
					
						
							| 
									
										
										
										
											2005-09-13 19:03:11 +00:00
										 |  |  |  </para> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |  <informaltable frame="all"> | 
					
						
							|  |  |  |   <tgroup cols="5"> | 
					
						
							|  |  |  |    <colspec colname="param" align="center" /> | 
					
						
							|  |  |  |    <colspec colname="type" align="center" /> | 
					
						
							|  |  |  |    <colspec colname="required" align="center" /> | 
					
						
							|  |  |  |    <colspec colname="default" align="center" /> | 
					
						
							|  |  |  |    <colspec colname="desc" /> | 
					
						
							|  |  |  |    <thead> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>Attribute Name</entry> | 
					
						
							|  |  |  |      <entry>Type</entry> | 
					
						
							|  |  |  |      <entry>Required</entry> | 
					
						
							|  |  |  |      <entry>Default</entry> | 
					
						
							|  |  |  |      <entry>Description</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							|  |  |  |    </thead> | 
					
						
							|  |  |  |    <tbody> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>name</entry> | 
					
						
							|  |  |  |      <entry>string</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							|  |  |  |      <entry><emphasis>default</emphasis></entry> | 
					
						
							|  |  |  |      <entry>The name of the cycle</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>values</entry> | 
					
						
							|  |  |  |      <entry>mixed</entry> | 
					
						
							|  |  |  |      <entry>Yes</entry> | 
					
						
							|  |  |  |      <entry><emphasis>N/A</emphasis></entry> | 
					
						
							|  |  |  |      <entry>The values to cycle through, either a comma | 
					
						
							|  |  |  |       delimited list (see delimiter attribute), or an array | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |       of values</entry> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |     </row> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>print</entry> | 
					
						
							|  |  |  |      <entry>boolean</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |      <entry><emphasis>&true;</emphasis></entry> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |      <entry>Whether to print the value or not</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>advance</entry> | 
					
						
							|  |  |  |      <entry>boolean</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |      <entry><emphasis>&true;</emphasis></entry> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |      <entry>Whether or not to advance to the next value</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>delimiter</entry> | 
					
						
							|  |  |  |      <entry>string</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							|  |  |  |      <entry><emphasis>,</emphasis></entry> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |      <entry>The delimiter to use in the values attribute</entry> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |     </row> | 
					
						
							|  |  |  |     <row> | 
					
						
							|  |  |  |      <entry>assign</entry> | 
					
						
							|  |  |  |      <entry>string</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							|  |  |  |      <entry><emphasis>n/a</emphasis></entry> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |      <entry>The template variable the output will be assigned | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |       to</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							| 
									
										
										
										
											2005-06-28 07:32:42 +00:00
										 |  |  |     <row> | 
					
						
							|  |  |  |      <entry>reset</entry> | 
					
						
							|  |  |  |      <entry>boolean</entry> | 
					
						
							|  |  |  |      <entry>No</entry> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |      <entry><emphasis>&false;</emphasis></entry> | 
					
						
							| 
									
										
										
										
											2005-06-28 07:32:42 +00:00
										 |  |  |      <entry>The cycle will be set to the first value and not advanced</entry> | 
					
						
							|  |  |  |     </row> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |    </tbody> | 
					
						
							|  |  |  |   </tgroup> | 
					
						
							|  |  |  |  </informaltable> | 
					
						
							| 
									
										
										
										
											2005-09-13 19:03:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  | <itemizedlist> | 
					
						
							|  |  |  |  <listitem><para> | 
					
						
							|  |  |  |   You can <varname>{cycle}</varname> through more than one set of values in | 
					
						
							|  |  |  |   a template by supplying a <parameter>name</parameter> attribute. | 
					
						
							|  |  |  |   Give each <varname>{cycle}</varname> an unique <parameter>name</parameter>. | 
					
						
							|  |  |  |  </para></listitem> | 
					
						
							|  |  |  |  <listitem><para> | 
					
						
							|  |  |  |   You can force the current value not to print with the | 
					
						
							|  |  |  |   <parameter>print</parameter>  attribute set to &false;. This would be useful | 
					
						
							|  |  |  |   for silently skipping a value. | 
					
						
							|  |  |  |  </para></listitem> | 
					
						
							|  |  |  |  <listitem><para> | 
					
						
							|  |  |  |   The <parameter>advance</parameter> attribute is used to repeat a value. | 
					
						
							|  |  |  |   When set to &false;, the next call to <varname>{cycle}</varname> will print | 
					
						
							|  |  |  |   the same value. | 
					
						
							|  |  |  |  </para></listitem> | 
					
						
							|  |  |  |  <listitem><para> | 
					
						
							|  |  |  |   If you supply the <parameter>assign</parameter> attribute, the output of the | 
					
						
							|  |  |  |   <varname>{cycle}</varname> function will be assigned to a template variable | 
					
						
							|  |  |  |   instead of being output to the template. | 
					
						
							|  |  |  |  </para></listitem> | 
					
						
							|  |  |  | </itemizedlist> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |  <example> | 
					
						
							| 
									
										
										
										
											2005-09-10 13:18:40 +00:00
										 |  |  |   <title>{cycle}</title> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |   <programlisting> | 
					
						
							|  |  |  | <![CDATA[ | 
					
						
							| 
									
										
										
										
											2004-04-13 08:46:28 +00:00
										 |  |  | {section name=rows loop=$data} | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  | <tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}"> | 
					
						
							|  |  |  |    <td>{$data[rows]}</td> | 
					
						
							|  |  |  | </tr> | 
					
						
							| 
									
										
										
										
											2004-04-13 08:46:28 +00:00
										 |  |  | {/section} | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  | ]]> | 
					
						
							|  |  |  |   </programlisting> | 
					
						
							| 
									
										
										
										
											2006-09-26 02:02:55 +00:00
										 |  |  |   <para>The above template would output:</para> | 
					
						
							| 
									
										
										
										
											2004-05-29 21:56:21 +00:00
										 |  |  |   <screen> | 
					
						
							|  |  |  | <![CDATA[ | 
					
						
							|  |  |  | <tr bgcolor="#eeeeee"> | 
					
						
							|  |  |  |    <td>1</td> | 
					
						
							|  |  |  | </tr> | 
					
						
							|  |  |  | <tr bgcolor="#d0d0d0"> | 
					
						
							|  |  |  |    <td>2</td> | 
					
						
							|  |  |  | </tr> | 
					
						
							|  |  |  | <tr bgcolor="#eeeeee"> | 
					
						
							|  |  |  |    <td>3</td> | 
					
						
							|  |  |  | </tr> | 
					
						
							|  |  |  | ]]> | 
					
						
							|  |  |  |   </screen> | 
					
						
							|  |  |  |  </example> | 
					
						
							| 
									
										
										
										
											2005-09-10 13:18:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-13 08:46:28 +00:00
										 |  |  | </sect1> | 
					
						
							|  |  |  | <!-- Keep this comment at the end of the file
 | 
					
						
							|  |  |  | Local variables: | 
					
						
							|  |  |  | mode: sgml | 
					
						
							|  |  |  | sgml-omittag:t | 
					
						
							|  |  |  | sgml-shorttag:t | 
					
						
							|  |  |  | sgml-minimize-attributes:nil | 
					
						
							|  |  |  | sgml-always-quote-attributes:t | 
					
						
							|  |  |  | sgml-indent-step:1 | 
					
						
							|  |  |  | sgml-indent-data:t | 
					
						
							|  |  |  | indent-tabs-mode:nil | 
					
						
							|  |  |  | sgml-parent-document:nil | 
					
						
							|  |  |  | sgml-default-dtd-file:"../../../../manual.ced" | 
					
						
							|  |  |  | sgml-exposed-tags:nil | 
					
						
							|  |  |  | sgml-local-catalogs:nil | 
					
						
							|  |  |  | sgml-local-ecat-files:nil | 
					
						
							|  |  |  | End: | 
					
						
							|  |  |  | vim600: syn=xml fen fdm=syntax fdl=2 si | 
					
						
							|  |  |  | vim: et tw=78 syn=sgml | 
					
						
							|  |  |  | vi: ts=1 sw=1 | 
					
						
							|  |  |  | --> |