I created a property under extended content in images called gallery folder. Here I select the folder and it displays the images. The code is working however when I save a different page, it takes down other pages using the same gallery.
@if(Model.HasValue("galleryFolder"))
{
var ImagesLists = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("galleryFolder");
var Collections = ImagesLists.Children;
foreach (var gimage in Collections)
{
<div class="col-sm-3 col-xs-4"><a href="@gimage.Url" class="gallery-content" data-lightbox-type="inline" data-lightbox-gallery="ProductImage"><img src="@gimage.Url" alt="" /></a></div>
}
}
Is it something to do with the page not grabbing a unique item? It's weird.
No, ever since I added this gallery it would affect other pages crashing them when I save on a different page. They're technically not "pages" as Merchello does it differently. (I Think)
Just wondering If I'm doing it properly or should do it differently. Here's the full page code.
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Merchello.Web.Models.VirtualContent.IProductContent>
@using Merchello.FastTrack.Ui
@using Merchello.Web
@using Merchello.Web.Models
@using Merchello.Web.Models.Ui.Rendering
@using Merchello.Web.Models.VirtualContent
@{
Layout = "FastTrack.cshtml";
// the Model passed here is IProductContent (virtual content) that is not generated by the Models Builder.
// However, it is a Typed IPublishedContent model that exposes product properties such as Price, SalePrice, etc.
// and the properties from the ContentType that was attached to the product in Merchello's back office.
// These can be accessed in the same way as any normal IPublishedContent property e.g. GetPropertyValue
}
<div class="title-area">
<div class="container-fluid">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<h1>@Model.Name</h1>
</div>
</div>
</div>
</div>
<section id="scroll">
<div class="product-details">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-sm-6">
@if (Model.HasValue("image"))
{
var mediaId = Model.GetProperty("image", true).DataValue;
var image = Umbraco.TypedMedia(mediaId);
<div style="width:100%">
<a href="@image.Url" class="gallery-content" data-lightbox-type="inline" data-lightbox-gallery="ProductImage">
<img src="@image.GetCropUrl(height: 450)" alt="@Model.Name">
</a>
</div>
}
@if(Model.HasValue("gallery"))
{
var ImagesList = Model.GetProperty("gallery", true).DataValue.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var Collection = Umbraco.Media(ImagesList);
@* if (Model.HasValue("image"))
{
var mediaId = Model.GetProperty("image", true).DataValue;
var image = Umbraco.TypedMedia(mediaId);
<div style="width:100%">
<div class="col-sm-3 col-xs-4">
<a href="@image.Url" class="gallery-content" data-lightbox-type="inline" data-lightbox-gallery="ProductImage">
<img src="@image.GetCropUrl(height: 450)" alt="@Model.Name">
</a>
</div>
</div>
}
*@
foreach (var image in Collection)
{
<div class="col-sm-3 col-xs-4"><a href="@image.Url" class="gallery-content" data-lightbox-type="inline" data-lightbox-gallery="ProductImage"><img src="@image.Url" alt="" /></a></div>
}
}
@*
@if(Model.HasValue("galleryFolder"))
{
var ImagesLists = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("galleryFolder");
var Collections = ImagesLists.Children;
foreach (var gimage in Collections)
{
<div class="col-sm-3 col-xs-4"><a href="@gimage.Url" class="gallery-content" data-lightbox-type="inline" data-lightbox-gallery="ProductImage"><img src="@gimage.Url" alt="" /></a></div>
}
}
*@
</div>
<div class="col-sm-6 pay">
@Html.Action("AddProductToBasketForm", "StoreBasket", new { area = "Merchello", model = Model })
<br />
<h3>Specifications</h3>
@Html.Raw(Model.GetPropertyValue<string>("brief"))
</div>
</div>
<hr/>
@if (Model.HasValue("description")){
<h2>Overview</h2>
@Html.Raw(Model.GetPropertyValue<string>("description"))
}
</div>
</div>
@if (Model.HasProperty("relatedProducts") && Model.HasValue("relatedProducts"))
{
<div class="row related-products">
<h3>Related Products</h3>
<hr />
@Html.Partial("_ProductBoxList", Model.GetPropertyValue<IEnumerable<IProductContent>>("relatedProducts"))
</div>
}
</div>
</div>
</section>
<[email protected](Model.GetPropertyValue<string>("brief"))-->
@helper Categories(IProductContent product)
{
var collections = product.Collections().ToArray();
if (collections.Any())
{
var pages = new List<Tuple<IProductCollection, IPublishedContent>>();
foreach (var col in collections)
{
var page = ExampleUiHelper.Content.GetCategoryPageForCollection(col.Key);
if (page != null)
{
pages.Add(new Tuple<IProductCollection, IPublishedContent>(col, page));
}
}
var needsComma = false;
<small>
Categories:
@foreach (var pc in pages)
{
@Umbraco.If(needsComma, ",") <a href="@pc.Item2.Url">@pc.Item1.Name</a>
needsComma = true;
}
</small>
}
}
The original "gallery" property was working then eventually stopped display images, this is why I switched to galleryFolder method.
Image Gallery Folder (Fast Track) (Umbraco 7.6.13)
I created a property under extended content in images called gallery folder. Here I select the folder and it displays the images. The code is working however when I save a different page, it takes down other pages using the same gallery.
Is it something to do with the page not grabbing a unique item? It's weird.
Hi Rylan
The problem is that you have the same images on different Umbraco pages?
Alex
No, ever since I added this gallery it would affect other pages crashing them when I save on a different page. They're technically not "pages" as Merchello does it differently. (I Think)
Just wondering If I'm doing it properly or should do it differently. Here's the full page code.
The original "gallery" property was working then eventually stopped display images, this is why I switched to galleryFolder method.
is working on a reply...