Try our conversational search powered by Generative AI!

Option for URL to open in new window in ContentReference single URL

Vote:
 

Hi,

I am using EPiServer 9 version. I have used Content  Reference and URL types for Link URLs. But in these EPiServer does not give built in option for the editors to choose to open a link in same or new window. This option extists for LinkItemCollection and Link in TinyMCE editor. 

Could anyone tell me how can I make a ContentRefrence or URL to give such option. And if it is not possible any other solution or work around to solve this limitation?

Thanks in advance.

Sanket Mahimkar

#143141
Jan 13, 2016 14:23
Vote:
 

You can create a block for this, or add an additional target frame property to your page/block. This is an example of the block approach.

[ContentType(AvailableInEditMode = false)]
public class PageLinkBlock : BlockData
{
   public virtual ContentReference Link { get; set; }

   [UIHint("TargetFrame")]
   public virtual int? TargetFrameRaw { get; set; }

   public string TargetFrame 
   {
      get
      {
         if (TargetFrameRaw.HasValue) 
         {
            var frame = EPiServer.DataAbstraction.Frame.Load(TargetFrameRaw.Value);
            return frame.Name;
         }

         return null;
      }   
   }
}

The view can look something like this:

@model PageLinkBlock

@Html.ContentLink(Model.Link, null, new { target = Model.TargetFrame })

On your page/block:

public virtual PageLinkBlock MyLink { get; set; }
#143145
Jan 13, 2016 14:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.