Displaying custom fields for an item in a table

The default layout for the Item (or Node) view displays the custom fields in an HTML definition list.  You can change this by creating a layout override for this view.

The directory default_template refers to the template that is set as the default for your site.  Please replace this name with the actual name of the template directory.

To create the layout override for this page, find the file:

/components/com_catalog/views/node/tmpl/default.php

Copy this to:

/templates/default_template/html/com_catalog/node/default.php

Open this new file in your programmers editor.

File the line in the source code that looks similar to the following:

	<h3><?php echo JText::_('Standard Features'); ?></h3>
	<dl>
		<?php foreach ($this->attributes as $attr) : ?>
			<?php if ($attr->value AND $attr->real_name) : ?>
			<dt><?php echo isset($flds[$attr->name]) ? $flds[$attr->name]->get('label') : $attr->name; ?></dt>
			<dd><?php echo JHTML::_('jxform.decorator', $flds[$attr->real_name], $attr->value); ?></dd>
			<?php endif; ?>
		<?php endforeach; ?>
	</dl>
	<?php endif; ?>

Change the code to the following:

	<h3><?php echo JText::_('Standard Features'); ?></h3>
	<table>
		<?php foreach ($this->attributes as $attr) : ?>
		<?php if ($attr->value AND $attr->real_name) : ?>
		<tr>
			<td><?php echo isset($flds[$attr->name]) ? $flds[$attr->name]->get('label') : $attr->name; ?></td>
			<td><?php echo JHTML::_('jxform.decorator', $flds[$attr->real_name], $attr->value); ?></td>
		</tr>
		<?php endif; ?>
		<?php endforeach; ?>
	</table>
	<?php endif; ?>

You may of course change the heading above the table to suit your site needs.

Save the file and upload the changes to your web site.