Custom templates and viewing gallery

Topics: Writing themes
Dec 18, 2011 at 2:57 PM

I created a custom content item and as part of a type associated Image Gallery. If I view the page that contains it is perfect.

Now I should castomize the page and then I created within the file of the theme:
Content-Annuncio.Detail.cshtml.
Now how do I get to review the gallery of images in my new page?

I paste my code the problem is after the hr tag

@{
    Orchard.ContentManagement.ContentItem contentItem = Model.ContentItem;
    string title = Model.ContentItem.Annuncio.NomeCognome.Value;
	var NomeAssociato = new HtmlString(title); 
}
 
<h1>@NomeAssociato</h1>
 
<div class="AssociatoDetail">
  
  <img src="@Url.Content(Model.ContentItem.Annuncio.Avatar.FileName)" alt="@Model.ContentItem.Annuncio.Avatar.AlternateText" class="ImgAssociatoDetail"/>
 
    @{ 
		string htmlContent = Model.ContentItem.Annuncio.Corpo.Text;
		var html = new HtmlString(htmlContent); 
	}
	<p>@html</p>
	
	@{
		var emailAssociato = new HtmlString(Model.ContentItem.Annuncio.Email.Value);
	}
	
	@if (emailAssociato != null)
	{
		<a href="mailto:@emailAssociato" title="contattami: @emailAssociato">
			<img  src="@Url.Content(Html.ThemePath("/Content/Images/send-mail.png"))" style="border-width:0px;" />
		</a>
	}
      
</div>
 
<hr/>
 
@using Mello.ImageGallery.Helpers
@using System.Web.Mvc.Html
@{ Style.Require("ImageGallery"); }
 
@{
 
   
    var item = Model.ContentItem;
    var parts = (List<Orchard.ContentManagement.ContentPart>) item.Parts;
    
   
    var imageGalleryPart = (Mello.ImageGallery.Models.ImageGalleryPart)parts.First(p => p.PartDefinition.Name == "ImageGalleryPart");
    var imageGallery = imageGalleryPart.ViewModel;
    var images = imageGallery != null ? imageGallery.Images : null;
}
 
@if (images != null)
{ 
    <div class="image-gallery">
        <ul>
            @foreach (var image in images)
            {
            <li>
                <a href="@image.PublicUrl" title="@image.Title">
                    asd
                </a>            
            </li>
            }                     
        </ul>     
    </div>
}
else<p>No elements in images</p>
}