Hi
I'm developing a team site for soccer team. I would like to show a random player (member of the players group) in a webpart on the startpage. Anyone with a sample how to handle this.
Regards
Peter
Hi
I'm developing a team site for soccer team. I would like to show a random player (member of the players group) in a webpart on the startpage. Anyone with a sample how to handle this.
Regards
Peter
Are the "players" users in the site, or is this just a list of players
If it's a list, I suggest the following psuedo code:
I assume you know how to write a webpart. If not, I suggest you read about this http://blogs.tamtam.nl/mart/CreateASharePoint2007WebpartStepByStep.aspx
Thanx
They are users in the site, do you know if it possible to handle that instead
Otherwise thanks for the sample
Peter,
In my blog (link below) you will find (search for "common coding tasks") how to connect to the SPWeb object using code.
After doing that, you have access (using the .Users property of the SPWeb object) to the list of users that:
You can then implement the same logic I mentioned earlier with randomly selecting one of them (use the SPUser object to get to their properties as are tracked in the site)
Thanks
I'll try that.
Peter
I had a situation where i wanted to select random records out of a list. I used a dataviewwebpart to get the data and edited the xsl to get random results.
Your steps actually helped me with this proces.
I did the following:
1. create a dataviewwebpart
2. connect to a list
3. make a variable that counts the rows
4. make a variable that does select="ddwrt:Random(1,$CountRows)"
5. then give the FirstRow and LastRow the select value of the variable name in step 4.
This worked for me without making an whole new webpart
Greetz
Thanks for your post Rick it was exactly what i was looking for. However as I am a newby to this I am getting stuck with your instructions. I have created a daatview web part that displays a single item form from the list. I am not to clear on:
1) Do I need to create a variable to count rows when there is already one there:
<xsl:variable name="dvt_RowCount" select="count($Rows)" />
I have added a variable to select the random item:
<xsl:variable name="randomtip" select="ddwrt:Random(1,$dvt_RowCount)" />
I have also changed the select value of the first and last rows:
<xsl:with-param name="FirstRow" select="randomtip" />
<xsl:with-param name="LastRow" select="randomtip" />
I only get the same item each time, which is the first item in the list.
Any help would be much appreciated.
Daniel
<xsl:with-param name="FirstRow" select="randomtip" />
<xsl:with-param name="LastRow" select="randomtip" />
<xsl:with-param name="FirstRow" select="$randomtip" />
<xsl:with-param name="LastRow" select="$randomtip" />