|
Member
|
Brad R
-
4/18/2011 11:54:04 AM
Menus with Query String Parameters
I have a site in which one class of users can access information from another class of users (I avoided the word "role" to avoid confusion with Kentico's role system for CMS Desk, although they are identified by Kentico roles). To accomplish this, the first class of users (I can't fully discuss the application, so we'll call them managers) have a page that lists all of the users they can access (we'll call them clients, because they are the clients of the managers) as hyperlinks that redirect them to a URL of the form:
/Manager/ClientInfo/<%# Eval("ClientUserName") %>/SubjectDataPage.aspx
I then have a page with the following Alias Path:
/Manager/ClientInfo/SubjectDataPage
giving it the following URL:
/Site/Manager/ClientInfo/SubjectDataPage.aspx
On that page, I have a Web Part that expects a query string parameter named "subjectUser" so I then used "Add new alias" to give it an alias of:
/Manager/ClientInfo/{subjectUser}/SubjectDataPage
All of this works fine. I click on one of the links and the data page shows for that client. The problem is, I have more than one data page and so I need to have a menu appear that shows all of the pages available for that client with links to those pages.
Potentially, I could do this with a repeater, if I can figure out how to set up the query (I haven't tried yet), but I'd like to do this with one of the standard menu controls, if possible. So far I've tried the following solutions:
1) Changing the page alias (not an additional page alias, but the first page alias), but there doesn't seem to be a meaningful way to do that
2) Use the menu redirect URL -- that seems to lead to an infinite loop in which the same page is requested over and over again
3) Set the menu to display items of the form "/Manager/ClientInfo/{subjectUser}/%", but then nothing gets displayed
I'm about to start looking more in depth at the SELECT clause of the menu, but I'm not sure if I'm even headed in the right direction. Any suggestions would be appreciated.
|
|
|
Member
|
Brad R
-
4/18/2011 12:05:24 PM
RE:Menus with Query String Parameters
After posting, I remembered a bit about macros and when I looked it up in the developer's documentation, I saw that query strings should be of the form {%name%}, so I changed the menu's filter to be as follows:
/Manager/ClientInfo/{%subjectUser%}/%
Still didn't resolve the issue, though. The menu still displays nothing.
|
|
|
Member
|
Brad R
-
4/18/2011 12:57:37 PM
RE:Menus with Query String Parameters
I have now managed to display a menu using a Repeater instead of one of the menu controls. To do so, I simply used a DocumentDataSource and a Repeater with an appropriate transformation. Although that meets my immediate needs, I'd still like to be able to use the TreeMenu control, both for sake of consistency (making styling easier) and because I anticipate having subitems that may be difficult to render with the Repeater. To this end, I'm thinking of subclassing the TreeMenu, but I'm hoping there is an easier solution built in.
|
|
|
Member
|
kentico_alleng
-
4/18/2011 1:28:21 PM
RE:Menus with Query String Parameters
Hi Brad,
The format " /Manager/ClientInfo/{%subjectUser%}/% " would require the URL to use a query string, such as ..ClientInfo?user=ActualUserName - The visited URL would need to supply the user name data.
You could use wildcard URLs, in which case the format is ../{subjectUser}/, but this will just redirect that URL to the query string format.
http://devnet.kentico.com/docs/5_5r2/devguide/index.html?wildcard_urls.htm
The DocumentDataSource solution may work best, but in order to use the datasource with the TreeMenu, you would need to create a custom TreeMenu web part.
Regards, Allen Greenhaw
|
|
|
Member
|
Brad R
-
4/18/2011 2:05:22 PM
RE:Menus with Query String Parameters
I was already using that article as a guide.
Rereading it, I noticed that it first suggests setting the document URL instead of adding a document alias. I had forgotten that the reason I wasn't able to do that before is because I was using a document link (I knew I was using a document link, but I didn't realize that was what was disabling the custom URL, which is why I was using "Add Alias"). In any case, when I tried using a duplicate document and setting the document URL, it made no difference.
The key issue isn't selecting what documents to display in the menu. To do that, I can simply specify /Manager/ClientInfo/% as the content to display in the menu. The problem is, if I do that, then the links generated by the TreeMenu will not include the query string part in either the path or as an actual query string. Consequently, the link simply takes me to a page that doesn't know what user was being talked about. If instead, I try querying for /Manager/ClientInfo/{subjectUser}/%, then it doesn't find the documents to display.
|
|
|
Member
|
kentico_alleng
-
4/18/2011 3:51:00 PM
RE:Menus with Query String Parameters
We've looked into this further, and it looks like the easiest path is to continue using a repeater part.
In order to connect the tree menu to the data source or to do something like populate the links at page load in the code-behind, a lot of customization would be needed for the tree menu web part.
If the repeater solution isn't going to work out and you'd like to customize the tree menu, let us know, and we'll check with our developers to see if they have any suggestions for simplifying the process.
Regards,
Allen
|
|
|