Recommendations seem to be added as last added, shown first. However I’m not keen for this, so wondering is there a way to reorder the recommendations? I’d even accept alphabetical worst case scenario.
Are you using the portal popup, or does your theme have a display built in?
Theme has it built in. https://aspect.priority.vision/
@PriorityVision might be able to help you out here!
Ok. Cheers. Messaged.
Had hoped that I’d missed an ordering within Ghost itself, but alas.
The portal popup does randomize them. :)
As you know, there’s unfortunately no way to randomise recommendations when using the {{recommendations}}
helper in one’s theme. I raised this issue with the Ghost team as soon as the functionality was released, and although it was regarded as being a good idea, nothing has happened in the interim.
The main reason why I thought a randomising feature would be beneficial is because it can appear that one’s recommendations are being listed from most favourite to least favourite. My blog has 21 sites it recommends, but only shows five of them in the sidebar (which one can click through to Portal’s listing to see them all – see here if you’d like).
My solution, hopefully just for the time being, is to utilise some JS in order to apply some randomisation.
$(function () {
var parent = $(".recommendations-list");
var divs = parent.children();
while (divs.length) {
parent.append(divs.splice(Math.floor(Math.random() * divs.length), 1)[0]);
}
});
The only problem I’ve had is that sometimes more than one listing of the same site is listed within those five displayed recommendations. For all I know those 21 sites are being outputted twice each, and sometimes the roll of the dice ends up depicting one site – and on the even more rare chance two sites – twice within the five displayed. From my guess it might not be the JS, as I tried out a different script which had the same bug. That’s partially why I hope Ghost will eventually add randomisation to the {{recommendations}}
helper, so I can ditch that JS.
But as your site will seemingly be displaying all recommendations, perhaps things won’t get doubled up and the bit of JS I mentioned above will do the trick for you. I changed the class to cater to the theme you mentioned, so if you add it to your theme’s footer code injection it should work just fine.
Hi @weemediahq, we’re using the official Ghost {{recommendations}}
helper, which displays recommendations in their original order. I also don’t understand why Ghost doesn’t allow us to change the order of added recommendations.
@Cathy_Sarisky, is there a way to randomize the order using this helper? I’ve checked the documentation, but seems like there is no random option.
While @Stromfeldt’s JavaScript solution might work, please note that our themes limit the number of recommendations shown on home pages. You’ll need to modify the home.hbs
template accordingly.
My memory is fuzzy on all this, but I think there was a reason that I didn’t try to limit things by adding limit=5
to the {{recommendations}}
helper when applying randomisation. Perhaps because it would only display the first five of the 20 recommendations my site has, rather than randomly displaying five out of the 20? I forget.
Anyway, I eschewed that limit
in favour of omitting with CSS, which with the JS successfully displays five random recommendations from the 20:
.section-recommendations .recommendation-list:nth-of-type(n+6) {
display: none;
}
Hi
Thanks for the reply. Ok, no worries i’ll accept things as they are and keep my recommendations tight to the 12 and accept the order as is. I can perhaps reorder them later manually when I have my top 12! ;)
Appreciate your time. Thanks.
Shirley
The recommendations helper takes an order parameter. Ghost Handlebars Theme Helpers: recommendations
There isn’t a randomize option (bummer), but there is an option to make them alphabetical!