Actions

Override:No Numbers in Category List

From Joomla! Documentation

Contents

Adding an Option

Stop hand nuvola.svg.png
Warning!

This is a core hack. Files you change as described on this page will be overwritten during updates of Joomla!. For more information, see Core hack.

You can add an option to turn on and off numbers in the category list by using this core hack. (The alternate method shown in the next section avoids the core hack with an override.)

Edit the XML File

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 file:

<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

Open the following file with your 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 <td> 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>

Removing Category List Numbers with an Override

The above option may give you better choices for future development but you can avoid the core hack by using this method.

Copy the File

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

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>