Developer forum

Forum » Templates » Loop itemslist in website settings

Loop itemslist in website settings

Aki Ruuskanen
Reply

Hi,

I have an ItemList in my Website Settings item called "SocialaMedier".

I am trying to loop through that itemlist in a module template. I'm trying with something like:

                    @foreach (var sm in GetLoop("Item.Area.SocialaMedier")) {
                        @sm.GetValue("Item.Area.SocialaMedier.Namn.Value")                    
                    }

The system name of the Itemlist is "SocialaMedier".

The itemlist contains Items where one of the fields has "Namn" as system name. 

I don't get any errors but I don't get any data either?

Any ideas?

Regards / Aki

 

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Aki

The template system does not understand Swedish :-).

We have the same concept on wrap - this is how we do (You have a .Value, why?):

@foreach (LoopItem socialitem in GetLoop("Item.Area.SocialIconInFooter"))
{
    sicon = socialitem.GetString("Item.Area.SocialIconInFooter.Icon");
    slink = socialitem.GetString("Item.Area.SocialIconInFooter.Link");
 
 <a href="@slink"><i class="fa @sicon fa-2x"></i>&nbsp;&nbsp;</a>
}
 
Aki Ruuskanen
Reply

I guess your code is in the master template? My code is in a module template but I guess it should work anyway. Changed my code to this but still no luck. No errors and no output. 

                   <div class="social-links">
                    @{
                        foreach (LoopItem sm in GetLoop("Item.Area.SocialaMedier")) {
                            String socialName = sm.GetString("Item.Area.SocialaMedier.Namn");
                            <div>@socialName</div>
                        }
                    }
                    </div>

 

 
Aki Ruuskanen
Reply

I do have data in the list. :)

http://screencast.com/t/8XFLRYu3kVB

 

 
Nicolai Høeg Pedersen
Reply

I'm not sure layout template tags are available in module templates... What does @TemplateTags() tell you?

 
Aki Ruuskanen
Reply

@TemplateTags() in the module template only gives me the module tags. 

Well I guess I can solve it with a "select  * from [dbo].[ItemType_SocialMediaLank]".  :)

 
Nicolai Høeg Pedersen
Reply

Or use Dynamicweb.Frontend.PageView.Current.Area.Item

 

You must be logged in to post in the forum