In my magazine archive page I have some folders which share few categories. For example I have the gadgets node which under it has all the articles which releate to cameras / gadgets / tech.
Now, what I want to do is to display each category in seperate. So for every child in the node(artice) I check
1: In wich page I am - by the page category (for example - gadgets / photography / etc) and then If the page is gadgets - there is another check:
2. If the current child (article) belong to gadgets. If yes I display it. I do it with a checkbox list for each article or page.
The problem is that I got like kind of "holes". Because it's like run on the whole node and then if for example I'm now on the gadgets page so if the first 2 articles for example were gadgets and then the next 10 were Photography so it will show 2 items and then just in the next page I'll see the next gadgets items (In the pagination I declare that it will show 10 items per page)
The question is: How do I exclude all the non relelvant items to the cuurent page (mean - If I'm on gadgets - all the photography items. If I'm on photpgraphy - all the gadgets items) and avoid the kind of 'holes'?
Here is my code:
var MagazineCategories = Model.GetProperty("MyMagazineMagazineCategory"); //get the checked item from the checkbox list
string Category_item = MagazineCategories.Value;
var MagazineID=1111; // initial the variable
switch (Category_item)
{
case "Gadgets":
MagazineID = 1111;
break;
case "Computers":
MagazineID = 1222;
break;
case "sport":
MagazineID = 1333;
break;
}
dynamic magazine_node = Library.NodeById(MagazineID); //get the right node according to the selected category
var magazine_pagesToList = magazine_node.Children.Where("Visible");
var itemsPerPage = 10;
var numberOfPages = Math.Ceiling((decimal)numberOfItems / (decimal)itemsPerPage);
foreach (var magazine_newsItem in magazine_pagesToList.OrderBy("createDate desc").Skip(currentPage*itemsPerPage).Take(itemsPerPage))
{
string ItemMagazineCategory = magazine_newsItem.GetProperty("MagazineCategory").Value;
if (Category_item == "Photography" || Category_item == "Gadgets") //Node with more than one category
{
if (Category_item == "Photography" && MagazineCategory == "Photography")
{
var selectedMedia = magazine_newsItem.Media("articleImg";
<div class="news_box">
<div class="img_frame">
<a href="magazine_newsItem.Url" class="img_link">
<img src=" />
</a>
</div>
<div class="news_frame">
<h2>
<a href="magazine_newsItem.Url" class="news_link">
magazine_newsItem.title
</a>
</h2>
<p>
magazine_newsItem.metaDescription
<a href="magazine_newsItem.Url" class="news_link">Read >></a>
</p>
</div>
<div style="clear:both"></div>
</div>
}
else if (Category_item == "Gadgets" && MagazineCategory == "Gadgets")
{
var selectedMedia = magazine_newsItem.Media("articleImg";
<div class="news_box">
<div class="img_frame">
<a href="magazine_newsItem.Url" class="img_link">
<img src=" />
</a>
</div>
<div class="news_frame">
<h2>
<a href="magazine_newsItem.Url" class="news_link">
magazine_newsItem.title
</a>
</h2>
<p>
magazine_newsItem.metaDescription
<a href="magazine_newsItem.Url" class="news_link">Read >></a>
</p>
</div>
<div style="clear:both"></div>
</div>
}
}
else //if it's just one category in node - then it's not a problem ..
{
var selectedMedia = magazine_newsItem.Media("articleImg";
<div class="news_box">
<div class="img_frame">
<a href="magazine_newsItem.Url" class="img_link">
<img src=" />
</a>
</div>
<div class="news_frame">
<h2>
<a href="magazine_newsItem.Url" class="news_link">
magazine_newsItem.title
</a>
</h2>
<p>
magazine_newsItem.metaDescription
<a href="magazine_newsItem.Url" class="news_link">Read >></a>
</p>
</div>
<div style="clear:both"></div>
</div>
}
}
If I'll add them to a list then it's double computing time - one time to build the list and then display the post.. - what about when I'll have 10,000 posts? I want to do it once the loop running ..
How to exclude nodes?
Hello (again .. :) )
What's the way to exclude child nodes?
In my magazine archive page I have some folders which share few categories. For example I have the gadgets node which under it has all the articles which releate to cameras / gadgets / tech.
Now, what I want to do is to display each category in seperate. So for every child in the node(artice) I check
1: In wich page I am - by the page category (for example - gadgets / photography / etc) and then If the page is gadgets - there is another check:
2. If the current child (article) belong to gadgets. If yes I display it. I do it with a checkbox list for each article or page.
The problem is that I got like kind of "holes". Because it's like run on the whole node and then if for example I'm now on the gadgets page so if the first 2 articles for example were gadgets and then the next 10 were Photography so it will show 2 items and then just in the next page I'll see the next gadgets items (In the pagination I declare that it will show 10 items per page)
The question is: How do I exclude all the non relelvant items to the cuurent page (mean - If I'm on gadgets - all the photography items. If I'm on photpgraphy - all the gadgets items) and avoid the kind of 'holes'?
Here is my code:
Thanks.
I think what you need to do is instead of doing a .Take(itemsPerPage). You want to add the items to a list until you have ten.
I am assumeing i have read this correctly. Charlie :)
If I'll add them to a list then it's double computing time - one time to build the list and then display the post.. - what about when I'll have 10,000 posts? I want to do it once the loop running ..
is working on a reply...