Web Part / Transform?! What to use

Tom F asked on December 1, 2016 03:21

Hi all, I have a scenario where I want to show hide markup based on if one or more values from document fields are present in an ASPX template.

I'm wondering should I be using a web part or transform? this is for the header bar of a page displaying the page title, any sub titles and some other controls based on conditional logic.

Sorry I'm new to Kentico and dusting off my webforms hat after razoring

Correct Answer

Brenden Kehren answered on December 1, 2016 16:27

If you have an editable text area or have a specific page type you're navigating to and know the field name, you can simply use a macro or a GetValue() method to do this work for you. In an editable or static type text control do something like {%ColumnName%}

Outside of that you can use CurrentDocument.GetValue("ColumnName")

1 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on December 1, 2016 04:52

If you're using aspx templates you won't use a webpart because those are for portal pages. You'll use a user control or a repeater of some sort with a transformation setup with it.

0 votesVote for this answer Mark as a Correct answer

Tom F answered on December 1, 2016 05:14

Thanks Brendan, Even if it it just for a single field? i.e. if the page has a sub heading I need to render some extra markup before and after but also add some conditional logic based on another document value..

I think the main area of difference is in Umbraco you're generally writing razor and can easily retrieve document values and apply conditional logic in the view so the concept of transforming everything feels a little foreign and the lack of linq to query related nodes

0 votesVote for this answer Mark as a Correct answer

Adam Gitin answered on December 1, 2016 13:40

You could check for the value of that one field like this:

CurrentDocument.GetStringValue("FieldName", "")

based on result show/hide

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.