0

I am building a work-around for an issue I've encountered with a product catalog. For some reason, the CSWP and Search Results web part are displaying spaces in the managed metadata term at the end of the friendly URL with '%20' instead of hyphens. I'm admittedly not a developer, but I'm learning my way around...

That said- is there a script that I can add to the Search Results "Item-Default" template that would take 'ctx.CurrentItem.Path' and replace the '%20' with a dash? I've tried piecing together similar scripts from other sites, but the URL never changes. Any assistance would be greatly appreciated!

0

I figured it out- in the display template, I repeatedly tried different variations of var newPath = ctx.CurrentItem.Path.replace(" "g,"-") but nothing was changing.

I found a different snippet that worked perfectly: var newPath = ctx.CurrentItem.Path.replace(/\s+/g,"-")

Now all of the spaces are replaced by hyphens and take me directly to the catalog item page like they should.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.