Override:No Numbers in Category List

From Joomla! Documentation

Revision as of 13:48, 29 March 2011 by Darrenforster99 (talk | contribs) (Added information on how to edit the code to provide a switch for turning numbers on and off, rather than fully turning them off.)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Adding an option[edit]

You can add an option to turn on and off numbers in the category list in the following way:

Edit the XML file[edit]

Open the following file with your favourite text editor

components/com_content/views/category/tmpl/default.xml

and add the following code into the parameters section of the xml

<param name="show_numbers" type="radio" default="1" label="Show Numbers" description="Show/Hide the article numbers">
  <option value="0">Hide</option>
  <option value="1">Show</option>
</param>

nb. if you don't want the default to be show the numbers change default="1" to default="0" in the param line.

Edit the PHP file[edit]

Open the following file with you favourite text editor

components/com_content/views/category/tmpl/default_items.php

Change line 42 from

<td class="sectiontableheader<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" align="right" width="5%">
  <?php echo JText::_('Num'); ?>
</td>

to

<?php if ($this->params->get('show_numbers')) : ?>
 <td class="sectiontableheader<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" align="right" width="5%">
  <?php echo JText::_('Num'); ?>
 </td>
<?php endif; ?>

then scroll down to line 71 (it was line 69, adding above text moves it down 2 lines) and change from

<td align="right">
  <?php echo $this->pagination->getRowOffset( $item->count ); ?>
</td>

to

<?php if ($this->params->get('show_numbers')) : ?>
 <td align="right">
  <?php echo $this->pagination->getRowOffset( $item->count ); ?>
 </td>
<?php endif; ?>

Once saved this will give you a new option called Show Numbers which will allow you to either show or hide the numbers as you please.

If you still want empty columns where the numbers are supposed to be move the php if statements within the tags as follows:

Line 42:

 <td class="sectiontableheader<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" align="right" width="5%">
  <?php if ($this->params->get('show_numbers')) echo JText::_('Num'); ?>
 </td>

Line 69:

 <td align="right">
  <?php if ($this->params->get('show_numbers')) echo $this->pagination->getRowOffset( $item->count ); ?>
 </td>


Below somebody else has put how to remove them all together, but the above option gives better choices for future development.

Removing all together[edit]

You may remove the numbers in a category list.

Copy the File[edit]

Copy the default_items.php file:

/components/com_content/views/category/tmpl/default_items.php

to the the html folder of your template:

/templates/<yourTemplate>/html/com_content/category/default_items.php

Edit the Copied File[edit]

Delete or comment out line 43:

<?php echo JText::_('Num'); ?>

If you still want an empty column where the numbers were, delete or comment out line 70:

<?php echo $this->pagination->getRowOffset( $item->count ); ?>

To eliminate the entire number column, delete or comment out lines 69 through 71:

<td align="right">
   <?php echo $this->pagination->getRowOffset( $item->count ); ?>
</td>