5
Use Insert JavaScript option
Specify Link description only (in your case 'Anchor Text')
Example
Field raw value
<link text="Anchor Text" linktype="javascript" url="" anchor="" />
HTML Output:
<a href="#">Anchor Text</a>
3
The reason why you cannot access those properties is because they are not know in the Scriban context provided by the SXA extensions. If you have i_item.CardLink in your Scriban template, that will match a Field object. This object has some properties (eg Target), but not the properties from a LinkField. And those are the ones you are requesting.
There is a ...
2
Try using an extension. See https://gist.github.com/auzick/c2e127ed4c6aef0f019eedc0ab738d2b.
using Scriban.Runtime;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.XA.Foundation.Abstractions;
using Sitecore.XA.Foundation.Scriban.Pipelines.GenerateScribanContext;
using System;
namespace Example.ScribanExtensions.Pipelines
{
public ...
1
In Scriban we have an embedded function sc_link
here you can find more details about it: sc_link
An example how to use it :
<a href="{{ sc_link i_datasourceItem }}">{{ i_datasource.display_name }}</a>
1
If you know the HTML already and also link field is specific no other changes then easy solution similar to Debu suggested -
@Html.Sitecore().Field(GLink.Fields.Link.ToString(), Model.Item,
new
{
text = <span> Model.Item.LinkFieldOptions(GLink.Fields.Link, LinkFieldOption.Text) </span>
})
Here LinkFieldOptions is an extension ...
1
One very simple way would be:
@Html.Sitecore().Field(linkfieldName, new {
text = "something"
})
Only top voted, non community-wiki answers of a minimum length are eligible