Jump to content

How get Pageimage object of PageArray from "Page" (PageArray) field type


Davidov
 Share

Recommended Posts

Good Day!

I am a beginer of processwire project. Thanks developers for your great work. this CMS is very Good!

I have a question: how get Pageimage object of PageArray from "Page" (PageArray) field type?

I have too tamplates: affiliates and their teachers. The template of affiliates have a field "teachers_list" wich is "Page" (PageArray) type.

When I vaffiliate teachers in a cycle, I can not access the teacher photo object and change its size.
 
I get an error returning: " Fatal error: Call to a member function maxWidth() on null ".
When i trying get URL attribute : $teacherItem->teacher_photo->url, i receive message: " Trying to get property of non-object ".
 
But this code works: $teacherItem->teacher_photo["url"].
 
The print_r function outputs the following information: "ProcessWire \ Pageimage Object ([changes] => Array ([0] => formatted) [hooks] => Array ([Pageimage :: pim2Load] => PageImageManipulator02-> getPageImageManipulator02 () in PageImageManipulator02.module ) [Data] => Array ([basename] => p16.jpg [description] => .... - ..... [tags] => [formatted] => 1 [modified] => 1487079115 [created ] => 1487079115))".
 
my PHP code:
foreach ($page->teacher_list as $teacherItem):
    $out .= "
            <tr>
              <td class=\"alignTop\">
                /* !!! my truble */
                <img src=\"{$teacherItem->teacher_photo->maxWidth(250)->url}\" />                                
                /* !!! my truble */
              </td>
              <td class=\"alignTop\">
                <div class=\"teach_style12\">
                  <strong>$teacherItem->fio</strong><br/>
                  $teacherItem->degree<br/>
                  $teacherItem->headline_detail                                    
                </div>
                <div class=\"teach_style9\">
                  $teacherItem->body
                </div>                   
              </td>
            </tr>";
endforeach;

Please, help me. Where is my error?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...