November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
This is exactly what I also wanted to do. But some of it are made internal.
Take a look at my rant about this :)
This is the code you need: And it makes a link aviable, and render it as a one link
[Serializable]
[PageDefinitionTypePlugIn()]
public class PropertyOneLink : PropertyLinkCollection
{
public LinkItem MyLink
{
get
{
if (this.Links != null && this.Links.Count > 0)
return this.Links[0];
return null;
}
}
public override EPiServer.Core.IPropertyControl CreatePropertyControl()
{
return new PropertyOneLinkControl();
}
}
public class PropertyOneLinkControl : PropertyDataControl, INamingContainer
{
// Fields
private Control editControl;
// Methods
public override void ApplyEditChanges()
{
try
{
this.PropertyLinkCollection.Links = ((IPropertyLinkCollectionEditControl)this.editControl).NewLinkCollection;
}
catch (Exception exception)
{
this.AddErrorValidator(exception.Message);
}
}
public override void CreateDefaultControls()
{
base.CopyWebAttributes(this);
foreach (LinkItem item in this.PropertyLinkCollection)
{
Literal literal = new Literal();
literal.Text = item.ToMappedLink();
this.Controls.Add(literal);
}
}
Repeater repeater;
public override void CreateEditControls()
{
this.editControl = this.Page.LoadControl(UriSupport.ResolveUrlFromUIBySettings("Edit/PropertyLinkCollectionEditControl.ascx"));
((IPropertyLinkCollectionEditControl)this.editControl).OriginalLinkCollection = this.PropertyLinkCollection.Links;
this.Controls.Add(this.editControl);
((IPropertyLinkCollectionEditControl)this.editControl).OriginalLinkCollection = this.PropertyLinkCollection.Links;
repeater = editControl.FindControl("Links") as Repeater;
editControl.PreRender += new EventHandler(editControl_PreRender);
}
void editControl_PreRender(object sender, EventArgs e)
{
var a = ((IPropertyLinkCollectionEditControl)editControl).NewLinkCollection;
if (repeater.Controls.Count > 0)
{
Control header = repeater.Controls[0];
header.Controls.Clear();
Literal l = new Literal();
l.Text = "<table class=\"epistandardtable\" style=\"width:200px;\">";
header.Controls.Add(l);
}
repeater.Visible = (a.Count > 0);
editControl.FindControl("AddLinkButton").Visible = !(a.Count > 0);
}
// Properties
private PropertyLinkCollection PropertyLinkCollection
{
get
{
return (base.PropertyData as PropertyOneLink);
}
}
}
YES !!!
sweet exactly what i needed
strange that epi didn't add out of the box supprt for links with target and title , every new site need it for SEO and etc.
I total agree with you. You could post a comment on the blog to raise you opinion.. http://bit.ly/9yCBMe
Am i correct, that after 5 years, this BASIC functionality (setting the target for a single link) is still not tackled in Episerver 9???? The last couple of weeks i have so many responses to my questions (which luckily did solve most of them!) which required me to 'hack' or in elegant terms 'write an extension or override' functionality that should be there from the start...
More and more i get the feeling that Episerver CMS is more of a basic CMS framework, instead of a fully functioning Content Management System.... :-(
Please i'm open for suggestion, so i hope you guys can prove me wrong.
Ron, I don't know what you're talking about. You have been able to set target on links as long as I can remember... If you want to extend the regular Url property, just create a block with the properties you need then a view for it.
And here's some code for you...
The link block:
[ContentType( GUID = "379e3ef7-6854-4cef-acbf-4eef3490db27", AvailableInEditMode = false)] public class LinkWithTextBlock : BlockData { [CultureSpecific] [Display] public virtual string LinkText { get; set; } [CultureSpecific] [DefaultDragAndDropTarget] [Display] public virtual Url LinkUrl { get; set; } }
Then in your page type:
[ContentType(GUID = "a04d5be6-bd62-4333-9645-058ed0c91246")] public class RegularPage : PageData { [Display] public virtual LinkWithTextBlock Link { get; set; } }
Your view for RegularPage
@Html.PropertyFor(m => m.CurrentPage.Link)
Then you have to create a partial view for LinkWithTextBlock.
And just to be clear; there is no Link property in EPiServer. But you have Url, which obviously only stores an URL. So if you want to store more information, like a link, just create a block.
This is my popup window for an url property for Episerver 9. As you can see there is no target option
As I wrote, it's an URL, not a link. If you need a link property you have to either develop a new property type yourself or use a local block (block as property).
Hi
i wanted to build custom property to url that uses the Information + Link target and not just the information ( i want it to behave like the link collection property ( it returns in code a linkitem with the information)
i tried to use the propertyurl control but it still render the information without the link traget