Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6675751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:53:55+00:00 2026-05-26T03:53:55+00:00

Is it possible to set the datasource location (not the datasource) to be a

  • 0

Is it possible to set the datasource location (not the datasource) to be a sitecore query?

What I’m trying to do is to have the sublayout set its datasource location to a folder under the item containing it (current item).

The sublayout datasource location should point to a folder under the current item. So I tried setting the datasource location to query:./Items/* but that did not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:53:55+00:00Added an answer on May 26, 2026 at 3:53 am

    You don’t need the query — the sublayout datasource location can simply use a relative path. e.g.

    ./Items
    

    Obviously though, that folder needs to exist already. I’ve been meaning to blog this code, and it may be overkill but I’ll post here since it may help you. The following can be added to the getRenderingDatasource pipeline to create a relative path datasource location if it doesn’t exist already. Add it before the GetDatasourceLocation processor.

    On the sublayout, you’ll want to add a parameter contentFolderTemplate=[GUID] to specify the template of the item that gets created.

    public class CreateContentFolder
    {
        protected const string CONTENT_FOLDER_TEMPLATE_PARAM = "contentFolderTemplate";
    
        public void Process(GetRenderingDatasourceArgs args)
        {
            Assert.IsNotNull(args, "args");
            Sitecore.Data.Items.RenderingItem rendering = new Sitecore.Data.Items.RenderingItem(args.RenderingItem);
            UrlString urlString = new UrlString(rendering.Parameters);
            var contentFolder = urlString.Parameters[CONTENT_FOLDER_TEMPLATE_PARAM];
            if (string.IsNullOrEmpty(contentFolder))
            {
                return;
            }
            if (!ID.IsID(contentFolder))
            {
                Log.Warn(string.Format("{0} for Rendering {1} contains improperly formatted ID: {2}", CONTENT_FOLDER_TEMPLATE_PARAM, args.RenderingItem.Name, contentFolder), this);
                return;
            }
    
            string text = args.RenderingItem["Datasource Location"];
            if (!string.IsNullOrEmpty(text))
            {
                if (text.StartsWith("./") && !string.IsNullOrEmpty(args.ContextItemPath))
                {
                    var itemPath = args.ContextItemPath + text.Remove(0, 1);
                    var item = args.ContentDatabase.GetItem(itemPath);
                    var contextItem = args.ContentDatabase.GetItem(args.ContextItemPath);
                    if (item == null && contextItem != null)
                    {
                        string itemName = text.Remove(0, 2);
                        //if we create an item in the current site context, the WebEditRibbonForm will see an ItemSaved event and think it needs to reload the page
                        using (new SiteContextSwitcher(SiteContextFactory.GetSiteContext("system")))
                        {
                            contextItem.Add(itemName, new TemplateID(ID.Parse(contentFolder)));
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to set a database role before running a report? I have
Possible Duplicate: Data not writing out to Database I'm trying to update a bit
Is it possible to set the selectedIndex of a combobox based on its value,
I have a Devexpress.XtraGrid.GridControl that I have set the DataSource to a DataTable .
Is it possible to set the datasource of a datagrid view using ajax? My
I have a datasource set in my Jetty.xml file that looks like this: <New
In Java SE it is possible set the cause of an exception using initCause
Is possible to set an image as an iPhone application unique icon in code
Is it possible to set code behind a resource dictionary in WPF. For example
Is it possible to set the cursor to 'wait' on the entire html page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.