Placing a condition into a row list

A general technical discussion area for patTemplate.
Locked
Edu
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Mar 16, 2006 4:25 pm

Placing a condition into a row list

Post by Edu » Tue Sep 26, 2006 8:01 am

Hi,

I'm creating a Joomla! component with patTemplate. When I want to show a list with a condition, the template only execute the condition for the first row.

Code: Select all

<mos:tmpl name="view">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<mos:tmpl name="rows">
	<tr>
		<th width="15%" align="left">Título:</th>
		<td width="85%">{ROW_TITLE} (# {ROW_ID}) </td>
	</tr>
	<tr>
		<th align="left">Categoría:</th>
		<td>{ROW_CATID}</td>
	</tr>
	<tr>
		<th align="left">Prioridad:</th>
		<td>{ROW_LEVEL}</td>
	</tr>
	<tr>
		<th align="left">Estado:</th>
		<td>{ROW_STATUS}</td>
	</tr>
	<tr>
		<th align="left">Publicado:</th>
		<td>{ROW_INDATE}</td>
	</tr>
	<tr>
		<th align="left">Mensaje:</th>
		<td>{ROW_DESCRIPTION}</td>
	</tr>
		<mos:tmpl name="options" type="condition" conditionvar="options">
			<mos:sub condition="0">
				<tr>
					<td colspan="2"><a href="index.php?option=com_debug&task=reply&id={ROW_ID}">Responder</a></td>
				</tr>
			</mos:sub>
			<mos:sub condition="1">
				<tr>
					<td colspan="2"><a href="index.php?option=com_debug&task=reply&id={ROW_ID}">Responder</a> | <a href="index.php?option=com_debug&task=level&id={ROW_ID}">Cambiar prioridad</a> | <a href="index.php?option=com_debug&task=status&id={ROW_ID}">Cambiar estado</a> | <a href="index.php?option=com_debug&task=delete&id={ROW_ID}">Eliminar</a> </td>
				</tr>
			</mos:sub>
		</mos:tmpl>
	</mos:tmpl>
</table>
</mos:tmpl>
And here, the PHP file:

Code: Select all

function view( $id ) {
		global $database, $my;
	
        // import the body of the page
        $tmpl =& debugHTML::createTemplate();
		
		$query = "SELECT * FROM #__debug_incidents WHERE id = $id OR parentid = $id ORDER BY indate";
		 
		// prepare the query in the database connector
		$database->setQuery( $query );
		 
		// retrieve the rows as objects
		$rows = $database->loadObjectList();
		 
		// DISPLAY DATA
		
		// load the template based on the selected skin
		$tmpl->readTemplatesFromInput( 'view.html' );		
		 
		// add the 'rows' to the rows template with a prefix
		$tmpl->addObject( 'rows', $rows, 'row_' );
		 
		if( $my->gid == 2 ) {
			$tmpl->addVar('options', 'OPTIONS', 1);
		}
		else {
			$tmpl->addVar('options', 'OPTIONS', 0);
		}

		// output the template
		$tmpl->displayParsedTemplate( 'view' );
    }

I'm new with patTemplate, where can I found more information? I read some threads about patTemplate, but I prefer to start with the most basic information.
Last edited by Edu on Tue Sep 26, 2006 10:58 am, edited 1 time in total.

Locked

Return to “patTemplate”