I'm having some trouble with the Related Links data type. I can't get it to display the links in the template. From what I've read I need to use a macro, but I'm not sure.
Here's what I've done:
Created a Data Type and picked the Related Links data type. Called it RelatedSchoolLinks
Created a new XSLT script file and Macro called RelatedSchoolLinks and chose the Related Links template. Left the file as is.
Dropped the Macro into the template file.
I have to be missing something but I can't tell what it is?
As suggested by Ian, make sure you get the alias of the property correct - typically it will be camel case, ie the first letter is lowercase, so in your case "relatedSchoolLinks".
By accident, we found the the built-in razro macro in the rich-text editor's pulldown. It was easy – worked just as expected provided the document type had the Related Links data and the its alias matched in the template.
Not having any luck pasting code in here as you can see below!!
@inherits umbraco.MacroEngines.DynamicNodeContext @{ if (Model.HasProperty("relatedLinks")) {
@foreach (var link in @Model.RelatedLinks) { string target = link.newwindow == "1" ? " target=\"_blank\"" : "";
When I first posted this question several months ago I was indeed trying to get it to work with XSLT. After I discovered the razor macro just worked, I abandoned putting anymore time into the XSLT option. Our developers prefer razor syntax anyway, so it was a win-win situation for us.
Glad you got it fixed. Razor does seem to be more friendly as most .net devs use MVC thus Razor or XSLT. Now i have been using XSLT a bit i dont find it so bad. Charlie.
Related Links not displaying 4.9
I'm having some trouble with the Related Links data type. I can't get it to display the links in the template. From what I've read I need to use a macro, but I'm not sure.
Here's what I've done:
Did you modify the propertyAlias in the xslt?
see lines 15-16:
<!-- Input the related links property alias here -->
<xsl:variable name="propertyAlias" select="string('links')"/>
I suspect you need <xsl:variable name="propertyAlias" select="string('RelatedSchoolLinks')"/> or whatever the alias is.
Hope this helps
Ian
hi Kurt
As suggested by Ian, make sure you get the alias of the property correct - typically it will be camel case, ie the first letter is lowercase, so in your case "relatedSchoolLinks".
Cheers, Nigel
Kurt did you get this fixed? Could you post the current XSLT you have and the property alias you have with the related links? Charlie :)
By accident, we found the the built-in razro macro in the rich-text editor's pulldown. It was easy – worked just as expected provided the document type had the Related Links data and the its alias matched in the template.
Not having any luck pasting code in here as you can see below!!
@foreach (var link in @Model.RelatedLinks) { string target = link.newwindow == "1" ? " target=\"_blank\"" : "";- @if (link.type == "internal") { @link.title } else { @link.title }
}
Hi Kurt, are you using Razor markup or XSLT? I thought at the top of this thread you were using XSLT? Charles.
Sorry for the confusion!
When I first posted this question several months ago I was indeed trying to get it to work with XSLT. After I discovered the razor macro just worked, I abandoned putting anymore time into the XSLT option. Our developers prefer razor syntax anyway, so it was a win-win situation for us.
Glad you got it fixed. Razor does seem to be more friendly as most .net devs use MVC thus Razor or XSLT. Now i have been using XSLT a bit i dont find it so bad. Charlie.
is working on a reply...