Developer forum

Forum » Templates » Check if paragraph is active

Check if paragraph is active

Michael Nielsen
Reply

I currently use the code below to count the number of paragraphs in a certain area (in this case my "suppliers" area).

int adverts = Paragraph.GetParagraphsByPageID(PageView.Current().Page.ID).FindAll(par => "suppliers".Equals(par.Container) && par.ShowParagraph).Count;

This counts all the active paragraphs in the area just fine, but if I set the publication period and the item has passed the expiry date, it still counts as an active paragraph.
How can I count the "real" active paragraphs and not the ones that has expired?


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Michael

This probably also performs like crap... You are double loading the paragraphs.

In your paragraph template you have ParagraphContainerCount, ParagraphContainerIsFirst and ParagraphContainerIsLast that indicates your.

BR Nicolai

Votes for this answer: 1

 

You must be logged in to post in the forum