Take the community feedback survey now.
Take the community feedback survey now.
 
                Use LinkItemCollection instead of Url.
public virtual LinkItemCollection LinkItem { get; set; }
Hi,
I can't use LinkItemCollection. Please suggest if you have some other option.
Hi Tanvi,
You can go with this-
Or create a PropertyList with two fields - URL and Target.
I think what you can do the best is to have a SelectionFactory in place. That will act as the link should open in a new window/not.
Step 1
 public class LinkItemTarget : ISelectionFactory
    {
        public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
        {
            return new ISelectItem[]
            {
                new SelectItem(){Text = "", Value = "" },
                new SelectItem(){Text = "Open the link in a new window", Value = "_blank" },
                new SelectItem() { Text = "Open the link in the whole window", Value = "_top" },
            };
        }
    }Step 2 - Decorate it on a different property specifically for links
        [CultureSpecific]
        [Display(Name = "Block Link Target", Description = "target for the Link", GroupName = SystemTabNames.Content, Order = 11)]
        [SelectOne(SelectionFactoryType = typeof(LinkItemTarget))]
        public virtual string BlockLinkTarget { get; set; }Step 3 - Using it on the page where your link is -
    var linkTarget = !string.IsNullOrEmpty(Model.BlockLinkTarget) ? string.Format("target={0}", Model.BlockLinkTarget) : string.Empty;
 <a href="someLinkUrl" @Html.Raw(linkTarget)>.......</a>The target in step 3 would set them to be the value that you choose from Episerver.
Hope it helps.
Hi Tanvi
Episerver recently introduced LinkItem in the Episerver Lab-On https://world.episerver.com/blogs/grzegorz-wiechec/dates/2020/6/episerver-labs---linkproperty/
Hopefully, it solves your problem.
 
    
    
    
I have this property:
public virtual Url Link { get; set; }
I want it to have an option in CMS to be able to open in new window,
How can I do it?
Please help