ASPX templates
Version 5.x > ASPX templates > Sending a "value" to the template View modes: 
User avatar
Member
Member
srizzetto-microgate - 7/28/2010 12:11:51 PM
   
Sending a "value" to the template
I would like to know if it is possibile to organize an ASPX template in order it can receive a parameter from a page (document) that is based on that template.

I'm not talking about a querystring, but something that I can edit for each instance of the documents in the backoffice (for example in the "Edit Regions & webparts" form ?)

Then it could be very useful in the codefile of the template to do at runtime some assumptions on the value of the parameter (eg to hide/show something, etc)

thx

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 8/6/2010 9:30:24 AM
   
RE:Sending a "value" to the template
Hello,


you can for example add some custom fields to document types you use. Then you can get the values of current document in ASPX template.


Best regards,
Helena Grulichova

User avatar
Member
Member
srizzetto-microgate - 8/6/2010 9:41:38 AM
   
RE:Sending a "value" to the template
Thanks Helena. Document TYpe is a simlple Page menu item.

Do you have an example of how to do ?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 8/10/2010 3:10:07 AM
   
RE:Sending a "value" to the template
Hello,

you can add the fields in:

Site manager -> Development -> Document types -> edit Page (menu item) -> Fields


Best regards,
Helena Grulichova

User avatar
Member
Member
srizzetto-microgate - 8/13/2010 11:11:10 AM
   
RE:Sending a "value" to the template
Helena,
sorry for my ignorance...

I create my field (eg. "MyAttribute" of type text), I see in the Form tab of the Page and I can fill with some values (eg "myValue")

Now, how can I retrieve ("myValue") from the codebehind of my aspx template ??

Something Like
if (Class.Method["myAttribute"] == "myValue")

thanks
Sandro

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 8/18/2010 3:13:26 PM
   
RE:Sending a "value" to the template
Hello,


You can get the value like:

// Get NewsTitle value of the News document

string newsTitle = (string) node.GetValue("NewsTitle");

Please see here for more details: Selecting nodes

Here you can see how you can get the current document: CMSContext class


Best regards,
Helena Grulichova

User avatar
Member
Member
srizzetto-microgate - 8/19/2010 1:53:56 AM
   
RE:Sending a "value" to the template
SPECTACOULOUS !

That's change my life :-)

thx