Filtering based on contentment Data List (duplicat...
# help-with-umbraco
m
I apologize in advance if I'm not summarizing the ask correctly but I'm not too familiar with this so bear with me. Also sorry for the duplication but this is the first time trying discord and I had ust posted this on Umbraco forum. We are on a Umbraco Cloud v8 site and use a contentment data list to specify our Robots SEO options for any given page on the website to be used as the meta robots content. It's a user defined checkbox list to allow our content editors to select from No Index, No Follow, etc. If no value is selected than index it the default I believe. For the various sitemap XML cshtml template files I'm trying to REMOVE any pages that are marked as no index.editor settings Property Settings So for the template file for the XML sitemap page I have the following query to get the pages I need (in this case it's an XML template just for our press releases)
Copy code
var newsselection = Umbraco.Content(Guid.Parse("xxxx-xxxxx-xxxxx(actual guid here)"))
    .DescendantsOfType("PressRelease")
.Where(x => x.IsVisible());
I guess my question is, can I add another where statement here which would not pull in pages that are listed as no index? I have tried a couple different ways but I'm not sure of the syntax to use here. We used to have a boolean option for hide from XML sitemap and that was easy just using:
.Where(x => x.Value<bool>("HideFromXmlSitemap") == false);
The structure has been updated to use the contentment data list but I'm just not familiar with how to work with it. I'm hoping it's a simple syntax I can use, any ideas? Thank you in advance!!! https://cdn.discordapp.com/attachments/1286027959404331061/1286027959660052632/Screenshot_2024-09-18_at_11.54.12_AM.png?ex=66ec6a5e&is=66eb18de&hm=fd553c3a20edebc87f949192e48fe091e54f1fe9a2a7a43f72ad7a57863b06b2& https://cdn.discordapp.com/attachments/1286027959404331061/1286027959991406622/Screenshot_2024-09-18_at_11.55.38_AM.png?ex=66ec6a5e&is=66eb18de&hm=c95adcec4631e2e3233203e88e7c2b68feb0bb425a3bc93be0bf11dcc3b1f5d5&
r
I believe datalists return ‘IEnumerable’ if it’s a multiple select; so ‘Where(x => x.Value<IEnumerable>(“robotsOptions”).Contains(“noindex”))’ should do the trick
2 Views