Keyword

[SOLVED] Adding ascending numbers in category_item.php for

  • S Ramirez Arellano No
  • S Ramirez Arellano No's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago #114453 by S Ramirez Arellano No
[SOLVED] Adding ascending numbers in category_item.php for was created by S Ramirez Arellano No
Hi

I wonder if any of you could help me please...

I have 5 different items inside a K2 category. What I want is to display an ascending number (starting at 1 and finishing at 5) for each item displayed in the category view page (category_item.php).

At the moment it shows just the title of each item in that page. I want to display:

1. Title (tem 1)
2. Title (item 2)
3. Title (item 3)...

etc

SO basically adding an ascending number to each item in category view.

How could I do that, please?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114454 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Adding ascending numbers in category_item.php for
Hello Salvador,

You need to edit your category_item.php and your category.php.

You can do this with two ways. The first one os changing the output of the items from <div>s to an orderer list <ol> and styling that <ol> or,

echoing the $key variable inside your category_item.php. Since $key has an auto incremental value and starts from 0 you will need something like this
					
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • S Ramirez Arellano No
  • S Ramirez Arellano No's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago #114455 by S Ramirez Arellano No
Replied by S Ramirez Arellano No on topic Re: Adding ascending numbers in category_item.php for
Thank you Krikor. I prefer your second solution. However when I add

<?php echo ($key+1); ?>

It appears the number 1 for each of the 5 items. Wouldnt I need a code like "foreach" or something like that? In that case which would be the exat code?

Thank you so muc in advance !

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114456 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Adding ascending numbers in category_item.php for
Oh I see,

The foreach() statement is located in category.php which loads the category_item.php template.
You can locate the correct items group (leading, primary, secondary etc..) and use the key there.

Eg. Look for
					
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • S Ramirez Arellano No
  • S Ramirez Arellano No's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago #114457 by S Ramirez Arellano No
Replied by S Ramirez Arellano No on topic Re: Adding ascending numbers in category_item.php for
Wow, it worked great ! Thank you so much !!!!!! You are a star

Please Log in or Create an account to join the conversation.