Jump to content

Mixin to change star ratings


Recommended Posts

Would it be possible to “hook” into data-ipsRating to change the output of the star elements? I have tried mixin:

ips.controller.mixin('mixinName', 'core.front.core.rating', true, function () {
      alert('mixin');
      this.before('initialize', function () {
        alert('before initialize');
      });
      this.before('_buildRatingElem', function () {
        alert('before _buildRatingElem');
      });
	});

There are three alerts. The first and second are called, the last one “before _buildRatingElem" not.

 

Link to comment
Share on other sites

1 minute ago, Nathan Explosion said:

Is there a _buildRatingElem function in the controller registered as core.front.core.rating?

This is not a controller, but a module. I suppose that is the reason the mixin does not work. I am trying with a controller now and fail again.

 

Link to comment
Share on other sites

1 minute ago, Sonya* said:

This is not a controller, but a module. I suppose that is the reason the mixin does not work

Just taken a look at the controller, and yep...no function called that (it's off in the ips.ui.rating module) so that will be why it's not working. Mixin is for controllers.

No idea what you are trying to do before the function, but as it is called in the init of ips.ui.rating then wouldn't before initialize meet the same need? (unless you need something that the init is providing? Again...no idea what you are trying to do)

 

Link to comment
Share on other sites

1 minute ago, Nathan Explosion said:

Again...no idea what you are trying to do)

I just need another output for the star rating.

Either hook into how the stars are built. This does not work, as this is a module.
Or send a rating remote from my template, that does not work either.

For example, instead of outputting 5 stars, I would like to print out:

  1. No.
  2. Rather no
  3. Don't know
  4. Rather yes
  5. Yes

The rating should be saved as usual. Just the output should be changed.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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