Page 1 of 1

[SOLVED] Frontend users:display random user info

Posted: Fri May 06, 2011 4:35 pm
by crossland
I need to display details of a random front end user on the home page. Each time the page is accessed, a different random user would be displayed. Has anybody done something like this?

CMS Made Simple: 1.9.2
FrontEndUsers: 1.12.12

Thanks

Re: Frontend users:display random user info

Posted: Fri May 06, 2011 7:15 pm
by uniqu3
To display user list on frontend you will first need CGUserDirectory then you could try smarty shuffle modifier, see http://forum.cmsmadesimple.org/viewtopic.php?t=47204

Re: Frontend users:display random user info

Posted: Mon May 09, 2011 4:27 pm
by crossland
Thanks very much for a useful pointer.

To get it to work, I created a new summary template (called random) in the Calguys User Directory containing the following:

{capture}{$users|@shuffle}{/capture}
...
{foreach from=$users[1].properties item='onepropvalue' key='propname'}
{* pull out values so we can display them in the desired format *}
{ if $properties.$propname.prompt == "Organisation name" }{assign var='iorg' value=$onepropvalue}{/if}
...
{/foreach}
{* display properties in correct format *}
<span class="textclass1" style="font-weight: bold">{$iorg}</span>
...
{ if $iurl != "" }
...
<a href="http://{$iurl}">Visit Website</a>
{/if}
...

Then I included the following on the front page:

{CGUserDirectory action='default' uid='10' summarytemplate='random'}

The site now shows a different front end user each time the home page is accessed. Thanks again.