Developer forum

Forum » CMS - Standard features » Link to item - loop fields of linked item i ItemPublisher

Link to item - loop fields of linked item i ItemPublisher

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

I have an itemtype (Called Ships) that contains a field of the type link to item (Called owner). Now from what i read here

 http://doc.dynamicweb.com/Default.aspx?ID=8083#3787

it should be possible to display the fields of the Linked Item.

 

I am using the item publisher to loop through several items and show them in a list.

My code is as shown below, but it doesn´t work. I get no output

 

@foreach (LoopItem i in GetLoop("ItemPublisher:Items.List")){

foreach (LoopItem i2 in @i.GetLoop("Item.Owner.Fields")){

@i2.TemplateTags()

}

}

 

I have also tried replacing @i.GetLoop("Item.Owner.Fields") with @i.GetLoop("ItemPublsiher.Owner.Fields") and @i.GetLoop("ItemPublisher.Item.Owner.Fields")

Still no result.

 

Is this not possible to achieve, or am I missing something?

/Hans


Replies

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Sorry, still no solution on this.

Anyone got an idea what I am doing wrong, or is this not possible?

 
Nicolai Pedersen
Reply

No clue.

Take a look at this snippet and see if it helps you:

https://github.com/dynamicweb/razor/blob/master/Files/Templates/Designs/Razor/ItemPublisher/List/List.cshtml

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi Nicolai

 

No, I Don´t think that helps. Doesn´t seem this code fetches the fields of a linked item via link to item field - as far as I can tell :/

/Hans

 

 
Vladimir
Reply

Hi Hans,

it seems just a typo in code. The second loop should be:

foreach (LoopItem i2 in @i.GetLoop("ItemPublisher:Item.Owner.Fields")){
(If field system name is Owner)

Anyway if  there some doubts - you could look tags from first loop:

@foreach (LoopItem i in GetLoop("ItemPublisher:Items.List")){
   @i.TemplateTags()
}

Best regards,

Vladimir

 

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Sorry for the hassle. You are right Vladimir.

It´s really embarrasing, but  turns out the problem was with the fieldType. It was link, and not link to Item (blush)

Sorry guys :/ But it works now, and is actually straight forward once the field type is correct.

/Hans

 

You must be logged in to post in the forum