Developer forum

Forum » Templates » Paragraph publication date

Paragraph publication date

Nikki Strømsnes
Reply

I am creating a news list with items. With the item publisher, I point to a section of page items. This works well and good, but I would like to include the publication date – which ideally should be the same as the standard publication date/activation date.

 

How would I output and use this in the item publisher list?


Replies

 
Mikkel Ricky
Reply

Just to be sure: you want to display the publication start and end date from the items, i.e. from the pages or paragraphs, right?

 
Mikkel Ricky
Reply

Whoops, I hit the send button a little too soon …

 

Currently, this publication dates are not available when rendering items, but maybe they should be. Right now, you have to create a publication date field on your item type and show that. This will also make it possible to sort the news items by publication date.

 

Actually, news items in the News V2 module also has a Date field (see http://goo.gl/A8kYsU) that is separate from the publication start and end dates.

 

Best regards,
Mikkel


 

 

  

 

 

 
Nikki Strømsnes
Reply

Thanks for your reply, Mikkel.

 

Each news "article" exists as a page item (because it makes a lot of sense, and creating categories based on standard navigation is easy).

 

What I want, is to output the value from the publication start date from each page item (see screenshot) in the item publisher.

 

 

 

Below is the basic idea of how I want it to look. It's a global news list, showing the latest five published news. Actually, I did try to create my own publication logic with custom fields, but it quickly became very messy, and I decided it was silly not to simply use the standard functionality for page publication, when it's already in place. I also don't think it makes much sense that to force the content editor to input two publication dates which are the same.

 

 
Mikkel Ricky
Reply

You will need a publication date field on your item type in order to sort the items by publication date – and I assume you want to do this.

If you're using Razor, you can get the item page activation date like this:

@{
var page = Dynamicweb.Content.Page.GetPageById(item.GetInteger("ItemPublisher:Item.Field.PageId"));
}

<span class="activation-date>"@page.ActiveFrom</span>
As I've mentioned, the activation and deactivation dates are not directly available in the template, but we'll take a look at if we should expose these dates.

  

 
Christian Rud Skovgaard
Reply

Hi Nikki,

These tags exposing activation and deactivation dates are now implemented in Dynamicweb 8.4.1.0

Kind Regards

Christian 

 
Sten Hougaard
Reply

Hi Christian,

Sounds interesting. Does this mean that every item will have two dates related to them? Could you perhaps reveal tagnames and perhaps an example?


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 
Christian Rud Skovgaard
Reply

Implemented with 2 new tags for page items and two new tags for paragraph item:

@ItemPublisher:Item.PageActiveFrom
@ItemPublisher:Item.ParagraphValidFrom
@ItemPublisher:Item.PageActiveTo
@ItemPublisher:Item.ParagraphValidTo

Kind Regards. Christian

 
Jacob Storgaard Jensen
Reply

Hi,

Just dropping in on the conversation... why the difference in naming conventions... ActiveFrom vs. ValidFrom?

In my mind a bit messy, but a nice feature to have!

 
Christian Rud Skovgaard
Reply

Hi,

We have now tried for a somewhat smarter solution. We only introduce 2 new tags:

 @ItemPublisher:Item.ActiveFrom and @ItemPublisher:Item.ActiveTo

These can be used for both pages and paragraphs.

Christian

 

You must be logged in to post in the forum