Skip to content

Commit e85d902

Browse files
committed
Added a story asset type for link builder expressions
1 parent d0f5bd9 commit e85d902

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/Libraries/SmartStore.Services/Cms/Blocks/StoryAssetAttribute.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public enum StoryAssetKind
4545
/// <summary>
4646
/// The property value is a manufacturer identifier.
4747
/// </summary>
48-
Manufacturer
48+
Manufacturer,
49+
50+
/// <summary>
51+
/// The property value is a link builder expression.
52+
/// </summary>
53+
Link
4954
}
5055
}

src/Libraries/SmartStore.Services/Cms/LinkResolverResult.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,31 @@ public string Link
7070
}
7171
}
7272

73+
/// <summary>
74+
/// Creates the full link expression including type, value and query string.
75+
/// </summary>
76+
/// <param name="includeQueryString">Whether to include the query string.</param>
77+
/// <returns>Link expression.</returns>
78+
public string GetExpression(bool includeQueryString = true)
79+
{
80+
if (Value == null)
81+
{
82+
return string.Empty;
83+
}
84+
85+
var result = Type == LinkType.Url
86+
? Value.ToString()
87+
: string.Concat(Type.ToString().ToLower(), ":", Value.ToString());
88+
89+
if (includeQueryString && Type != LinkType.Url && !string.IsNullOrWhiteSpace(QueryString))
90+
{
91+
return string.Concat(result, "?", QueryString);
92+
}
93+
94+
return result;
95+
}
96+
97+
7398
public override string ToString()
7499
{
75100
return this.Link;

0 commit comments

Comments
 (0)