UPDATE (01/17/08): Ovaj blog entry govori o više hiperveze XSL dobrote: http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/rewriting-links-in-search-results-xslt.
Pregled i cilj: I had created a simple bar chart to serve as component on a dashboard. I’ll save the details on building charts for another post, ali nisam izmislio tu tehniku (niti upitnik, u tom slučaju). It turned out there was a bug in the chart and while I fixed that, I took the opportunity to convert some labels into hyperlinks that pointed at the underlying list behind the graph. Na primjer, there is a label with value "Hold". I wanted to turn the label into a hyperlink so that the user could click on it and drill down to the specific entries in the list whose status value is "Hold".
Koraci:
- Use visual studio for sharepoint-aware intellisense.
- Copy the DVWP’s XSLT into visual studio (create a blank project, add an XSL file to the project).
- Copy the link you want to use into the clipboard.
- Paste it into the right location in the XSL.
- Convert URL argument separators on the query string from "&" to "&"
- Url-encode individual arguments.
- Wrap that inside an <href…> </a>
Primjer:
I have an URL:
http://[server]/[site]/Lists/Open Positions/AllItems.aspx?View={84EEA2F5-121B-40B7-946F-0FA704A1DAA1}&FilterField1=Recruiter&FilterValue1=Hold
I convert it into:
<a href="Lists/Open Positions/AllItems.aspx?View={84EEA2F5-121B-40B7-946F-
0FA704A1DAA1}&FilterField1=Recruiter&FilterValue1=Hold"> Hold: </a>
I have manually transformed the first argument from:
{84EEA2F5-121B-40B7-946F-0FA704A1DAA1}
na:
%7b84EEA2F5-121B-40B7-946F-0FA704A1DAA1}
(In this, the open brace transforms to { and the closing brace transforms to })
The second and third arguments’ parameters ("FilterField1=Recruiter" and "FilterValue1=Hold" respectively) do not need to be url-encoded because they do not contain any unsafe characters.
Bilješke:
This technique should generally work anywhere you want to embed a hyperlink in XSLT where the hyperlink includes parameters on the URL such as:
http://[server]/[site]/Lists/Open Positions/AllItems.aspx?View={84EEA2F5-121B-40B7-946F-0FA704A1DAA1}&FilterField1=Recruiter&FilterValue1=Hold
I got the URL itself by accessing the custom list and manually filtering on the status column (labeled "Recruiter" gore).