0

I'm using the SelectMany attribute in the following way:

[SelectMany(SelectionFactoryType = typeof(TagsSelectionFactory))]
public virtual string Tags { get; set; }

With the following SelectionFactory:

public class TagsSelectionFactory : ISelectionFactory
{
    public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
    {
        var articleTags = DataFactory.Instance.GetChildren<ArticleTagPage>(new ContentReference(18));
        var tags = new List<SelectItem>();
        foreach (var item in articleTags)
        {
            tags.Add(new SelectItem { Text = item.TagName, Value = item.ContentLink.ID });
        }
        return tags;
    }
}

This is how I retreive the values:

var articleObjects = DataFactory.Instance.GetChildren<ArticlePage>(currentPage.ArticlesLocation);
foreach (var item in articleObjects)
{
    //this is where i get the csv value
    var tags = item.Tags;
}

//ArticleTagPage.cs
[ContentType(DisplayName = "ArticleTagPage", GUID = "0401929a-903a-414f-acd1-61ad11319462", Description = "")]
public class ArticleTagPage : PageData
{
    [CultureSpecific]
    [Display(Name = "Tag Name", Description = "", GroupName = SystemTabNames.Content, Order = 1)]
    public virtual string TagName { get; set; }
}

All of the ArticleTagPage are located under an ArticleTagsContainerPage. The purpose is to manage each article a collection of tags, kind of like SO questions with their tags.
My problem is that once the property gets populated, it holds a comma (,) delimited string, and this can cause a problem in cases where the data contains a comma.
Is it possible to alter the delimiter to something like a ; or a |, or maybe just return a collection of the selected values?

Yoav
  • 3,326
  • 3
  • 32
  • 73
  • Looking at your selection factory, it appears all option _values_ will be integers (which is what will be saved in the property), so you wouldn't have to worry about the delimiter? – Ted Nyberg Dec 01 '16 at 14:59
  • the Tags property is filled with a csv string. It seems like the value is used only when setting the property, not when retrieving them. I'll update my question with my retrieval code. – Yoav Dec 01 '16 at 15:11
  • Sure, but wouldn't `item.Tags` be a CSV of stringified integers like `"123,456,789"` etc, since you've selected a list of integers (content IDs)? – Ted Nyberg Dec 01 '16 at 15:18
  • nope, it returns the text properties of the select item, not the values – Yoav Dec 01 '16 at 15:19
  • That's odd, it should definitely store the **values**. Could you try `item.ContentLink.ID.ToString()` in your selection factory? Otherwise you could make use of the `PropertyList` API to have an enumerable property type. – Ted Nyberg Dec 01 '16 at 15:28
  • Another idea could be to change your property type to `ContentReferenceList` and stick with using the content ID as the item value in your selection factory. Your property would then contain references to your selected `ArticleTagPage` pages. – Ted Nyberg Dec 01 '16 at 15:30
  • Can you please post the relevant parts of `ArticleTagPage` – Eric Herlitz Dec 01 '16 at 22:51
  • @EricHerlitz updated – Yoav Dec 04 '16 at 07:50

0 Answers0