Developer forum

Forum » Development » pageView.Layout is null

pageView.Layout is null

Ronni Hansen
Ronni Hansen
Reply

Hi DW!

I have run into a problem after upgrading to DW9.5. (I dont know if 9.5 is the actual problem, but maybe you can lead me in the right direction).

I have a TranslationHelper method, that does something like the following

var paragraph = _dwParagraphService.GetParagraph(paragraphId);

var pageView = Dynamicweb.Frontend.PageView.GetPageviewByPageID(paragraph.PageID); 

Dynamicweb.Rendering.Translation.Translation.GetTranslation("SomeTranslation", pageView.Layout.Design)

For some reason Layout is null in pageView.Layout, which causes an exception, and im quite stuck on where to look.

Hope you can help :)

BR Ronni


Replies

 
Nicolai Pedersen
Reply

Damn, that is an ugly hack :-).

Why not just do _dwParagraphService.GetParagraph(paragraphId).Page.Layout.Design?

And then call the version of GetTranslation that takes a culture maybe.

Creating a pageview instance inside another pageview is performance wise a bad idea...

BR Nicolai

 
Ronni Hansen
Ronni Hansen
Reply

Haha lets just call it legacy code ;-)

Ill pass in the paragraph directly to the translationhelper and try out your solution; and have a look at the one with the culture!

Thanks!

 

 

You must be logged in to post in the forum