Forum Discussion
Really?? I'm speechless... so to actually get a list of all existing ranks we have to contact support even though there is an official API call for it in v1 and v2 and neither of them works properly...
The v1 call to ranks/list asks for a specific user login or id (via URL parameter) which completely defeats it's purpose, I don't want a USER's rank, I want ALL ranks in the community (this time for translation purposes).
<response status="error"> <error code="306"> <message> A required feature is not configured: user-node-rank. </message> </error> </response>
The v2 call documented here https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=ranks#fields-id just returns an error on a 17.12 (17.12-release r1803051017) community...
{ "status" : "error", "message" : "undefined collection: ranks", "data" : { "type" : "error_data", "code" : 602, "developer_message" : "", "more_info" : "" }, "metadata" : { } }
SuzieH do you know why this is documented but then throws an error like that? It says nowhere that this has to be custom enabled by support?? I'm simply trying
SELECT * FROM ranks
If that's really something that needs to be first enabled by support, please add it to the docs so any confusion and waste of time is avoided in the future.
I came across this topic when researching possibilities to export user ranks. I did end up opening a support ticket to ask if it is possible, but unfortunately it is not.
Please consider voting on my product idea here: Allow user ranks to be exported to CSV
- luk8 years agoBoss
Thanks for the idea lilim, upvoted!
Meanwhile I wrote a dirty export script, just execute it within the inspector console on the ranks page in Admin, it will inject a download link called "Export Ranks" which when clicked will give you a text file to download (just rename the .properties file to .csv or .txt or whatever you need, doesn't really matter, its just text):
jQuery('<div id="ranks" />').hide().appendTo('body'); // create fake container for .load() // The ranks are embedded with an iFrame in Admin, and // therefore not accessible directly via JS, that means we first have to fetch // the content of the iFrame, inject it into the DOM and then work from there... jQuery('#ranks').load(jQuery('.lia-component-admin-widget-user-rankings').prop('src') + ' .admin_cell:last', function() { var ranks = []; // initialize variable jQuery('#ranks a[href*="edit&ranking.id"]').each(function() { var $item = jQuery(this); var title = $item.parents('td:first').next().text().trim(); var id = $item.prop('href').split('=').pop(); var output = `rank.${id}.title = ${title}`; ranks.push(output); //console.log(output); }); //console.log(ranks.join("\n")); var file = null; var buffer = new Blob([ranks.join("\n")], {type: 'text/plain'}); var $link = jQuery('<a href="#" download="ranks.properties">Export Ranks</a>').insertBefore('.lia-component-admin-widget-user-rankings'); // If we are replacing a previously generated file we need to // manually revoke the object URL to avoid memory leaks. if (file !== null) { window.URL.revokeObjectURL(file); } file = window.URL.createObjectURL(buffer); $link.attr('href', file); });
of course you would need to tailor the output to your needs, I needed it for rank translation, therefore it is generating the proper text keys to overwrite rank names...