How to consolidate star rating results across multiple language contexts?

Hey everybody,
My website has two language versions. I use Babel and two different contexts. The site contains musician profile pages with star rating. Visitors should be able to rate musicians (their video presentations attached). FiveStarRating aka SimpleRating works just fine. Unfortunately, there isn’t synchronization across the two language versions of the page. When you click that stars on one language version nothing changes on another one.

Is there a way to create different language versions of the page under the same id? I heard it’s easily done in WP but I didn’t find anything for MODX Revo.

Please help! :slight_smile:

Yes, it seems that my crucial problem is how to get the same MODX resource (same ID) to display different language versions and urls /en/, /de/, /ru/ whatever.

Yes, this is the kind of functionality WP will have with some sort of plugin, while in Modx we do it ourselves.

For this one, I think what you want is a global tv that holds and displays the data, you want users of all language versions to, together, rate the artists.

Its just a counter, each artist would have one. The tv can hold the updated average

1 Like

Since Babel is used there’s a template variable that connects contexts. It is called babelLanguageLinks and stores association between language versions of the page as web:3;eng:101 (where “web” is a default language context - Russian in my project). Wish I knew what to do with this :slight_smile: I am not a programmer.

Don’t worry about the contexts and babel, you just need a common place to store your ratings which can easily be accessed from anywhere.
I’d recommend using a custom database table but I’m not sure how your star rating extra works.

Is this the one?
I can’t seem to find the Github repo for it but judging by the instructions it sounds like it stores the ratings in a custom database table but links it to a specific resource id.

This is a wild assumption but what about storing the results based on the resource ids of the first context only. You could then refer to that resource id in the snippet call on the translated resource on another context.

For example say resource id #1 is on your first context and resource #2 is on your second context. On resource id #2, you would make a snippet call with:

[[!SimpleRating? &id=`1`]]

So then if it works the way I’m assuming, resource id #2 uses the rating data for resource #1.

To make it dynamic, you could use Babel’s Translation snippet to get the linked id number:

1 Like

Yeah the languagelinks isn’t useful here, thats a bable function. Most Extras do one thing only.

@digitalpenguin has some good advice. One question, are the artists registered users? If so, you could use one of the fields of the user profile to store the rating. But, that might not be the best solution.

This could all be done easily with tvs, dont you think? Just display the rating space and the current overall rating, then save the new rating to a tv and have the updated rating in the same tv

Thank you do much. This is exactly what I needed and works like a charm! Actually it turned out to be a logical and very simple solution. I like the idea, that Babel provides an easy way to retrieve ids of linked resources. It might be useful elsewhere and I just didn’t know about it (using Babel for the first time).

No, not registered. The festival collects data one time (I tried NewsPublisher but then switched to Formit2Resource). And profiles are mainteined by website editors.

I try to rely on ready solutions as much as possible because my php skills are very basic + I am not confident about using php in MODX environment (never remember what goes where). Will have more questions in sep threads :slight_smile: err… I like MODX very much, made over 60 websites - all for musicians and labels. However, technically they all are very simple. This latest project is a bit of a challenge for me.

1 Like