Actions

Difference between revisions of "Override:No Numbers in Category List"

From Joomla! Documentation

(Added information on how to edit the code to provide a switch for turning numbers on and off, rather than fully turning them off.)
(Edited punctuation. Added italic markup. Added note about avoiding the core hack with an override.)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
==Adding an option==
+
==Adding an Option==
You can add an option to turn on and off numbers in the category list in the following way:
+
{{CoreHackNotice}}
  
===Edit the XML file===
+
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
 
Open the following file with your favourite text editor
  
components/com_content/views/category/tmpl/default.xml
+
''components/com_content/views/category/tmpl/default.xml''
  
and add the following code into the parameters section of the xml
+
and add the following code into the parameters section of the XML file:
  
 
<source lang="xml">
 
<source lang="xml">
Line 17: Line 18:
 
</source>
 
</source>
  
nb. if you don't want the default to be show the numbers change default="1" to default="0" in the param line.
+
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 the PHP File===
 +
Open the following file with your favourite text editor:
  
Open the following file with you favourite text editor
+
''components/com_content/views/category/tmpl/default_items.php''
 
+
components/com_content/views/category/tmpl/default_items.php
+
  
 
Change line 42 from
 
Change line 42 from
Line 43: Line 43:
 
</source>
 
</source>
  
then scroll down to line 71 (it was line 69, adding above text moves it down 2 lines) and change from
+
Then scroll down to line 71 (it was line 69, adding above text moves it down 2 lines) and change from
  
 
<source lang="php">
 
<source lang="php">
Line 61: Line 61:
 
</source>
 
</source>
  
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.   
+
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:
+
If you still want empty columns where the numbers are supposed to be, move the PHP ''if'' statements within the <nowiki><td></nowiki> tags as follows:
  
 
Line 42:
 
Line 42:
Line 81: Line 81:
 
</source>
 
</source>
  
 +
==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.
  
Below somebody else has put how to remove them all together, but the above option gives better choices for future development.
 
 
==Removing all together==
 
 
You may remove the numbers in a category list.
 
 
===Copy the File===
 
===Copy the File===
 
Copy the default_items.php file:
 
Copy the default_items.php file:
Line 97: Line 94:
  
 
===Edit the Copied File===
 
===Edit the Copied File===
 
 
Delete or comment out line 43:
 
Delete or comment out line 43:
 
<source lang="php">
 
<source lang="php">
Line 114: Line 110:
 
</td>
 
</td>
 
</source >
 
</source >
 
 
  
 
[[Category:Tips and tricks]]
 
[[Category:Tips and tricks]]
 
[[Category:Tips and tricks 1.5]]
 
[[Category:Tips and tricks 1.5]]
 
[[Category: Overrides]]
 
[[Category: Overrides]]

Latest revision as of 16:01, 31 July 2012

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>