Developer forum

Forum » Development » News:Manchet in Razor

News:Manchet in Razor

Jonas Mersholm
Reply

Hi DW,

I'm trying to render a news Manchet if it exists, and if not, render the first x chars. The code goes as like this

                  @if(!String.IsNullOrEmpty( l.GetString("News:Manchet") ) ) {
                          <div class="teaser">@l.GetValue("News:Manchet")</div>
                      } else {
                          <div class="teaser">@l.GetValue("News:FirstXChar")</div>
                      }

The code works fine, the problem is that the Manchet is completely blank, which means that it will always render my fallback "firstXChar".  even though the "show teasertext" in the module is set to true, and the news actually have teaser/manchet texts set. Do you guys have any idea what this could be?

 

best regards.

Jonas


Replies

 
Mikkel Ricky
Reply

In the news list, @News:Manchet is only set if the module setting "Teaser text" is "Show teaser text". Otherwise (when it's "Show first …"), @News:FirstXChar is set. This means that @News:Manchet cannot be used to check if a news item actually has a teaser text.

In Razor you can handle this like shown in this template: https://github.com/dynamicweb/itembasedmodules/blob/master/Files/Templates/Designs/itembasedmodules/ItemPublisher/List/News_Item_List.cshtml#L44-L50

Best regards,
Mikkel 

 

You must be logged in to post in the forum