Developer forum

Forum » Templates » Area Item and ItemPublisher

Area Item and ItemPublisher

Thomas Schroll
Reply

Hi

I'm using the Area Items to show a footer on a solution (like solution set) and I'm trying to use the Item based news module. When I use Itempublisher to show the news item the area item fields are not available. Is there something I can do to also show area items?

Regards Thomas


Replies

 
Mikkel Ricky
Reply

Are your trying to access the area item inside each item in your item publisher, i.e.

@foreach (var item in GetLoop("ItemPublisher:Items.List")) {
  @* Use the area item? *@
}

?

 
Mikkel Ricky
Reply

Using Razor, you can access the website item using the Area property on the Pageview object:

<pre>Pageview.Area.Item: @string.Join("\n", Pageview.Area.Item.ToArray())</pre>

Similarly, the page item is available

<pre>Pageview.Item: @string.Join("\n", Pageview.Item.ToArray())</pre>

 

 

 

 
Thomas Schroll
Reply

Hi Mikkel

I found the problem. I cannot use

<!--@Global:Page.Content(<!--@Item.Area.Footer_Content_Page_ID-->)-->

Neither in a html nor cshtml template. I have to use

<!--@Global:Page.Content(@Pageview.Area.Item["Footer_Content_Page_ID"])-->
I can see that the template documentation mention something about item based pages, but I don't understand it :)
Anyway, thanks for your help:)
Regards Thomas
 
Mikkel Ricky
Reply
This post has been marked as an answer

We're using <!--@Global:Page.Content(<!--@Item.Area.Footer_Content_Page_ID-->)--> in html templates in our solution set [http://solutionset.dynamicweb.dk/] without any problem. You have to check that Item.Area.Footer_Content_Page_ID is set, though. See https://github.com/dynamicweb/solutionset/blob/master/Files/Templates/Designs/eCommerce/MasterPages/Main.html#L62-L64 for an example.

What version of Dynamicweb are you using?

As you note, in Razor templates you must use Razor syntax for getting the content page id (@Pageview.Area.Item["Footer_Content_Page_ID"]) and the old syntax for @Global:Page.Content.

Best regards,
Mikkel


 

 

 

 

Votes for this answer: 1
 
Thomas Schroll
Reply

Hi Mikkel

Let me clarify: I can use the dw only tags when all templates are html, but if I am using a razor template the pure dw tags cannot be used in a html master.

I'm using DW8.3.0.6

Regards Thomas

 

 
Mikkel Ricky
Reply

When using Razor you have to write

<!--@Global:Page.Content(@Pageview.Area.Item["Footer_Content_Page_ID"])-->

and when using HTML you have to write

<!--@Global:Page.Content(<!--@Item.Area.Footer_Content_Page_ID-->)-->

The <!--@Global:Page.Content(...)--> is the same in both template systems and is processed after all other Razor expressions or template tags have been processed.

 

 

 

 

 

You must be logged in to post in the forum