Multisite question.... how do I output the site into the assets path? currentSite won't work because its the admin panel, so the current site is always the default site.

Using the below, I will always get /default/footer-content with this, regardless of which site is having its field edited.

enter image description here

New contributor
cherrykoda is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • So, I got this to work accounting for the ?site=foo parameter in entries and the /admin/globals/foo/globalsethandle formats used in globals .... but this feels ultra fragile. {{ craft.request.getParam('site')|length ? craft.request.getParam('site') : craft.request.getSegment(2) }}/footer-content – cherrykoda 2 days ago

Try using {site.handle} instead of {{currentSite.handle}} and it should work ok.

  • Here are the docs on the "object syntax" used for Entry URI formats: craftcms.com/docs/3.x/entries.html#entry-uri-formats - The answer given above is a shortcut for {object.site.handle} - good to know if you ever need to use entry data in the URI - it's all accessible under the object variable. – James Smith 2 days ago

Your Answer

cherrykoda is a new contributor. Be nice, and check out our Code of Conduct.

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.