Greetings!! I'm an absolute newbie trying to learn Umbraco and MVC in general.Currently I'm using version 7.2 and trying to make an image gallery from Warren's Razor Recipe series. I'm trying to convert the legacy Razor code to partial view macro but end up nowhere. Can anyone help me with this please?
The one below is Mr. Warren's original code
<div id="grid">
@{
foreach (var gallery in Model.Children)
{
if (gallery.HasValue("galleryImage"))
{
var MediaGalleryFolder = Library.MediaById(gallery.galleryImage);
var noPhotos = MediaGalleryFolder.Children.Count();
//Get the first image in the folder
var imageNode = MediaGalleryFolder.Children.First();
var imageURL = imageNode.umbracoFile;
<article>
<a href="@gallery.Url">
<!-- Use ImageGen querystring to automatically generate a thumbnail & setup fallback image -->
Please help in converting code to Partial View
Friends,
Greetings!! I'm an absolute newbie trying to learn Umbraco and MVC in general.Currently I'm using version 7.2 and trying to make an image gallery from Warren's Razor Recipe series. I'm trying to convert the legacy Razor code to partial view macro but end up nowhere. Can anyone help me with this please?
The one below is Mr. Warren's original code
<div id="grid">
@{
foreach (var gallery in Model.Children)
{
if (gallery.HasValue("galleryImage"))
{
var MediaGalleryFolder = Library.MediaById(gallery.galleryImage);
var noPhotos = MediaGalleryFolder.Children.Count();
//Get the first image in the folder
var imageNode = MediaGalleryFolder.Children.First();
var imageURL = imageNode.umbracoFile;
<article>
<a href="@gallery.Url">
<!-- Use ImageGen querystring to automatically generate a thumbnail & setup fallback image -->
<img src="/ImageGen.ashx?image=@imageURL&height=173&width=173&crop=resize&align=center&altImage=/img/no-image.png" alt="@gallery.Name"/>
<div>
<h4>
<!-- Display page name & format the price to £150,000.00 -->
@gallery.Name<br />
@noPhotos photos
</h4>
</div>
</a>
</article>
}
}
}
</div>
Ritzin this post may help http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/52617-Fancybox-Intergration-with-v711-Image-cropper
or this one http://our.umbraco.org/projects/website-utilities/slimsy/slimsy-feedback/56635-Convert-Banner-partial-to-Slimsy
Thank you Keith for the quick help. Really appreciate that. Let me go through those posts...
this can also help http://24days.in/umbraco/2014/how-to-set-up-an-umbraco-site/
Keith, this worked for me
<div id="grid">
@{
foreach (var gallery in CurrentPage.Children)
{
if (gallery.HasValue("galleryImage"))
{
var MediaGalleryFolder = Umbraco.Media((int)gallery.galleryImage);
var noPhotos = MediaGalleryFolder.Children.Count();
//Get the first image in the folder
var imageNode = MediaGalleryFolder.Children.First();
var imageURL = imageNode.umbracoFile;
<article>
<a href="@gallery.Url">
<!-- Use ImageGen querystring to automatically generate a thumbnail & setup fallback image -->
<img src="/ImageGen.ashx?image=@imageURL&height=173&width=173&crop=resize&align=center&altImage=/img/no-image.png" alt="@gallery.Name"/>
<div>
<h4>
<!-- Display page name & format the price to £150,000.00 -->
@gallery.Name<br />
@noPhotos photos
</h4>
</div>
</a>
</article>
}
}
}
</div>
is working on a reply...