Chris Falkenstein

Remove "#" from index number on repeater label

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

Share this post


Link to post
Share on other sites
adrian    7,664

Sorry, ignore the stupidity in my last post - I did #1 instead of #n

I'll look into it and get back to you in a minute :)

Share this post


Link to post
Share on other sites
adrian    7,664

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

Share this post


Link to post
Share on other sites
adrian    7,664
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

Share this post


Link to post
Share on other sites
adrian    7,664
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!

Share this post


Link to post
Share on other sites

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


  • Recently Browsing   0 members

    No registered users viewing this page.