Tuesday 1 October 2024

Sitecore SXA virtual media folder :: Customized!!

 If you worked with Sitecore SXA before, you must be familiar with the virtual media folder concept, mainly the folder that you usually see with the name "Media" under each website you create under your tenant, but have you ever tried or needed to create such folder out of a tenant with a different name than MEDIA as example, lets say to make it easier for your content author to get into a long path folder. not? then don't try, its not going to work! interested, keep reading! 



If you're not familiar with the virtual/scoped media folder in Sitecore SXA, I would suggest you start by reading the following Sitecore doc: 

https://doc.sitecore.com/xp/en/developers/sxa/latest/sitecore-experience-accelerator/configure-the-media-library-for-an-sxa-site.html


Now, if you needed to create a virtual/scope folder in any location out of the SXA tenant and in different name, it will not work! and when discussing this with Sitecore support we found that the reason behind that is that the folder name MUST be "Media" as its hard coded in some JS file, so here we go, one thing we know that we should do, is to update that JS file to count for anything else, or at least some other name I need. below you can see the change where I needed to name my folder "documents". 

File path is: sitecore/shell/Applications/Content Manager/SxaEditor.js

See the OR statement in line 27. 

In addition, as extra tip, be aware that you're not limited to use the OOTB template for a virtual folder, you can create your own and then customize the data view, mainly the master data view, open show config page and look for <dataviews> and then in code, inherit Sitecore.XA.Foundation.Multisite.Views.SxaDataView  .


Hopefully the above gave you some insights how to work and customize Sitecore SXA virtual media folder. 

No comments:

Post a Comment