Output user profile picture using Mustache helper

Re: Output user profile picture using Mustache helper

by Richard Jones -
Number of replies: 0
Picture of Plugin developers Picture of Testers

Hi Justin

Thanks for the response and I hope you're well old buddy.

I got something similar from the userpix/index.php example:

        foreach ($students as $student) {
            $studentlist = array();
            $studentlist['name'] = $student->firstname;
            $rs = $DB->get_record_select("user", "id = '$student->id'", null, user_picture::fields());
            $studentlist['pic'] = $this->output->user_picture($rs);
            $data->students[] = $studentlist;
        }

Where students is a list of course student users from an SQL function in the block code. 

Then in the template:

    {{#students}}
      <ul class="list-group">
        <li class="list-group-item list-group-item-warning">  {{{pic}}} {{name}}</li>
    </ul>
    {{/students}}

And the result looks like this:

the block

So there's life in the old block yet smile

Absolutely the pix template helper is only designed to take pix from the relevant pix folder (a moment's thought would have told me that).  I need to find out how to write a template helper but that's something for another day.

However, maybe this will help someone searching the forums for something similar.

Best wishes

Richard

Average of ratings: Useful (2)