Getting page type field of a specific page

Jason D asked on June 13, 2017 02:25

I have been searching and searching for something that would work or help me, and I'm not getting anywhere.

I have the code below, and the portion with "ModelName" needs to come from the Node Alias Path page as it's part of a different ("Product page") page type/ document type than the SKU information. If I just use "ModelName", it displays the current document's Model Name, but not the SKU I'm trying to refer to (it's a Related Products web part and transformation).

   <div class='item column column-block'>
  <a href='/Products/{% SKUName %}'>
    <img class='product-img' alt='{% SKUName %}' src='{% SKUImagePath #%}' />
    <div class='product-desc'>
      <h3>{% SKUName %} <span> 

      ----> This isn't working 
      {% Documents['/Products/All/' && SKUNumber].DocumentContent("ModelName") %}<---- 

      <p>{% "/Products/All/" + SKUNumber %}</p>
      <p class='summary'>{% LimitLength(SKUDescription, 70, "...") #%}</p>

Correct Answer

Anton Grekhovodov answered on June 13, 2017 10:53

Hi Jason,
I see some mistakes in your code:
1) Try to use double quote character " instead of single one ' in expressions like Documents["/Products"]
2) The expression Documents['/Products/All/' && SKUNumber] looks wrong because Documents object can load a document by index or NodeAliasPath value and it's not clear what you tried to do with AND operator. So here, I think you should use + operator, so expression will be like Documents["/Products/All/" + SKUNumber].
3) Property DocumentContent returns content of widgets or editable webparts, for example if you have editable text webpart with name EditableText1, you can get this value via DocumentContent["EditableText1"]
4) If you want to get some values from page type propertiesm, you can use the name of the property to get the value (example: Documents["/Home"].DocumentName) or use GetValue method (example: GetValue("DocumentName")

So your result expression will be like {% Documents["/Products/All/"+SKUNumber].GetValue("ModelName") |(identity)GlobalAdministrator%}. And Kentico has Macro Console in System Application, where you can check any macro expression and see how they work

1 votesVote for this answer Unmark Correct answer

Recent Answers

Jason D answered on June 13, 2017 15:36

Thank you Anton! That worked.

The apostrophes versus double quotes, as well as the "&&" logic operator versus "+" were actually things that I was changing up to see if maybe I wasn't understanding how it was resolving... which I wasn't, clearly :)


0 votesVote for this answer Mark as a Correct answer

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