Sitecore CMS and everything related RSS 2.0
 Tuesday, October 14, 2008
Getting sublayout parameters in Sitecore 5

One of the popular questions about Sitecore is how to get sublayout parameters. Sitecore 5 way of doing that involves advanced API – parsing layout definition for the current item, finding the rendering item, etc.

Sitecore 6 makes this simple enough to remember – the parameter string is stored as a “sc_parameters” attribute of the sublayout.

string rawParameters = Attributes[“sc_parameters”];
NameValueCollection parameters = Sitecore.Web.WebUtil.ParseUrlParameters(rawParameters);

Tuesday, October 14, 2008 1:07:29 PM (FLE Standard Time, UTC+02:00)  #    Comments [5]
Sitecore | Crestone
Tuesday, October 21, 2008 3:32:41 PM (FLE Standard Time, UTC+02:00)
Hi and thanks for a great blog.

That sounds really good.
But i have one problem.

I use a sublayout two times on a template.. and give them diference parameters...
Each time my sublayout is called.. the above lines you mention, gives me only the first sublayouts parameters.
How can i get the correct paramters for both my uses of the sublayout?

I have a layout where where i need to render som boxes on both left and right side of the content. So i made a sublayout to render boxes.. it takes some parameters to which side it used, so i know which field of in the item to get the content for the boxes. But when i use the above lines.. i only get the first sublayouts parameters.

I tried using the old way to get the values, but the problem is the same.

/Brian
Tuesday, October 21, 2008 6:20:49 PM (FLE Standard Time, UTC+02:00)
Brian,

This does sound like a bug, thanks for letting us know. If you have access to Sitecore support system, you should register a ticket and hopefully support team will be able to find a workaround, and we'll be able to fix it in the product later.


Wednesday, October 22, 2008 8:24:17 AM (FLE Standard Time, UTC+02:00)
Thanx Alexey

I will open a ticket.

/Brian Nielsen
Wednesday, October 29, 2008 3:57:08 PM (FLE Standard Time, UTC+02:00)
Hi Alexy

Thanks for the quick fix of the error.

Is there a way to get the DataSource instead of the old way, as you image shows?

/Brian :-)
Monday, December 08, 2008 5:53:26 PM (FLE Standard Time, UTC+02:00)
Hi Alexy,

Does this work with registered Web Controls too? Or is there another way to access the parameters from within a Web Control? I ask only because after attending a Sitecore 6 certification class and passing, I wanted to change a sublayout into a web control. The sublayout was able to correctly get the parameters, but the web control is not. Attributes["sc_parameters"] returns null.

Thanks for any assistance you might lend.

Pete
Pete Navarra
Comments are closed.
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
 Alex de Groot
Few words about SiteCore from Holland
 Alexander Shyba
Sitecore Support
 Anders Dreyer
Anders Dreyer on Sitecore Development
 Jakob Christensen
Sitecore Core Development
 Lars Fløe Nielsen
Lars's ramblings about development and business processes
 Ole Thrane
Sitecore API
 Runi Thomsen
Runi Thomsen Sitecore Toughts
 The Sitecore Experience
The Sitecore Experience
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Alexey Rusakov
Sign In
Statistics
Total Posts: 211
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, Alexey Rusakov
DasBlog theme 'Business' created by Christoph De Baene (delarou)