Jump to content

Remove "#" from index number on repeater label


Chris Falkenstein
 Share

Recommended Posts

Hi all.  I setup a repeater. I'd like to use a unique label for each repeater item.  I opted to use the repeater's index number. Perfect, but it's adding the pound (#) sign in the label.  Can I include the repeater index number without the pound sign?  How?  See my repeater item below (screen shot)

ss.jpg

Link to comment
Share on other sites

Sorry for the delay - I got sidetracked.

You can fix this easily with a little hook magic. Place this in your /site/ready.php file:

$this->addHookAfter("InputfieldRepeater::renderRepeaterLabel", function($event) {
    $return = $event->return;
    $event->return = str_replace('#', '', $return);
});

 

  • Like 1
Link to comment
Share on other sites

1 minute ago, Chris Falkenstein said:

Thanks.  What's this ready.php file do?  I suppose I need to create this?

Yes, you will need to create it. Basically any code in that file will be run when ProcessWire is "ready". You can read more about it here:

https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks

  • Like 1
Link to comment
Share on other sites

2 minutes ago, Chris Falkenstein said:

Wonderus!

Yeah, hooks are very cool and not as scary as they may first appear. 

Be sure to check out the Captain Hook panel in Tracy - it gives you a list of available hooks for each file/class/module in ProcessWire. It can take a little time to figure out what you should be looking for, but once you do, the skies the limit!

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...