Developer forum

Forum » Templates » Get Value Page custom property items

Get Value Page custom property items

Roop K. Rusbjerg
Reply

Hello,

I made a custom item type for page property items and I want them executed in the page layout file.

Why is this piece of code not working?

<section style="background-color: @GetValue("Item.Page.SectionBgColor");">
<div id="pagecontent" class="dwcontent @GetValue("Item.Page.ContentStyle")"  title="content">
</div>
</section>

Looking to an answer :)

Best wishes,

Roop

page-properties.jpg

Replies

 
Nicolai Pedersen
Reply

Is your layout template viewmodel based or template tag based?

If it is viewmodel based you need to use @Model.Item.GetValue instead

 
Roop K. Rusbjerg
Reply

Hey Nicolai,

I never worked with template View Models, so I'm guessing this is Template tag based.

Is that why it's not working?

Best wishes

Roop

 
Nicolai Pedersen
Reply

Show me the entire template, and I can tell you.

 
Roop K. Rusbjerg
Reply

Master and Page Templates attached.

I tried with @Model.Item, it didn't work.

 
Roop K. Rusbjerg
Reply
 
Roop K. Rusbjerg
Reply

Hello,

Just a little ekstra info, I have already used GetValue Item.Area for some custom items under website settings and that works fine.
But the info is called into a regular <p> tag.

So I guess they are not so useful in an inline style or as a value for a class?

Any help or answer is appretiated :)

Best wishes,

Roop

 
Nicolai Pedersen
Reply
This post has been marked as an answer

You can try adding them in a variable

var bgcolor = @GetValue("Item.Page.SectionBgColor")
var style= @GetValue("Item.Page.ContentStyle")
<section style="background-color: @bgcolor;">
<div id="pagecontent" class="dwcontent @style"  title="content">
Votes for this answer: 1
 
Roop K. Rusbjerg
Reply

Hey Nicolai!

That worked yes

Thank you!

Best wishes,

Roop

 

 

You must be logged in to post in the forum