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

From Joomla! Documentation

(New page: To remove the numbers in a category list copy this file: \components\com_content\views\category\tmpl\default_items.php to the the html folder of your template. templates\yourTemplate\h...)
 
(Edited punctuation. Added italic markup. Added note about avoiding the core hack with an override.)
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
To remove the numbers in a category list copy this file:
+
==Adding an Option==
 +
{{CoreHackNotice}}
  
 +
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.)
  
\components\com_content\views\category\tmpl\default_items.php
+
===Edit the XML File===
 +
Open the following file with your favourite text editor
  
to the the html folder of your template.
+
''components/com_content/views/category/tmpl/default.xml''
  
templates\yourTemplate\html\com_content\category\default_items.php
+
and add the following code into the parameters section of the XML file:
  
 +
<source lang="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>
 +
</source>
  
Open the file.
+
NB: If you don't want the default to be show the numbers, change ''default="1"'' to ''default="0"'' in the param line.
  
Delete or comment out line 43
+
===Edit the PHP File===
<?php echo JText::_('Num'); ?>
+
Open the following file with your favourite text editor:
 
  
Delete or comment out line 70 if you still want an empty column where the numbers were
+
''components/com_content/views/category/tmpl/default_items.php''
<?php echo $this->pagination->getRowOffset( $item->count ); ?>
 
  
Or lines 69-71 to eliminate the whole column
+
Change line 42 from
<pre>
+
 
<td align="right">
+
<source lang="php">
<?php echo $this->pagination->getRowOffset( $item->count ); ?>
+
<td class="sectiontableheader<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" align="right" width="5%">
</td>
+
  <?php echo JText::_('Num'); ?>
</pre>
+
</td>
 +
</source>
 +
 
 +
to
 +
 
 +
<source lang="php">
 +
<?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; ?>
 +
</source>
 +
 
 +
Then scroll down to line 71 (it was line 69, adding above text moves it down 2 lines) and change from
 +
 
 +
<source lang="php">
 +
<td align="right">
 +
  <?php echo $this->pagination->getRowOffset( $item->count ); ?>
 +
</td>
 +
</source>
 +
 
 +
to
 +
 
 +
<source lang="php">
 +
<?php if ($this->params->get('show_numbers')) : ?>
 +
<td align="right">
 +
  <?php echo $this->pagination->getRowOffset( $item->count ); ?>
 +
</td>
 +
<?php endif; ?>
 +
</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. 
 +
 
 +
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:
 +
 
 +
<source lang="php">
 +
<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>
 +
</source>
 +
 
 +
Line 69:
 +
 
 +
<source lang="php">
 +
<td align="right">
 +
  <?php if ($this->params->get('show_numbers')) echo $this->pagination->getRowOffset( $item->count ); ?>
 +
</td>
 +
</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.
 +
 
 +
===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:
 +
<source lang="php">
 +
<?php echo JText::_('Num'); ?>
 +
</source >
 +
 
 +
If you still want an empty column where the numbers were, delete or comment out line 70:
 +
<source lang="php">
 +
<?php echo $this->pagination->getRowOffset( $item->count ); ?>
 +
</source >
 +
 
 +
To eliminate the entire number column, delete or comment out lines 69 through 71:
 +
<source lang="php">
 +
<td align="right">
 +
  <?php echo $this->pagination->getRowOffset( $item->count ); ?>
 +
</td>
 +
</source >
  
 
[[Category:Tips and tricks]]
 
[[Category:Tips and tricks]]
 
[[Category:Tips and tricks 1.5]]
 
[[Category:Tips and tricks 1.5]]
 +
[[Category: Overrides]]

Revision as of 17:01, 31 July 2012

Adding an Option[edit]

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[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 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[edit]

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[edit]

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[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>