chuguruk Posted April 4, 2016 Share Posted April 4, 2016 Hi there, I have no clue how to resolve this problem: There is list of pages with users There is list of pages with devices In device template i have field "page" to select proper user In front end I have table where I'm looping through devices displaying title and user id. Problem: I can't display user name. <?=$device->user?> is displaying id of user (1114) <?php $user_name = $pages->get(1114); echo $user_name; ?> is displaying name correctly (not loop) <?php $user_name = $pages->get($device->user); echo $user_name; ?> - not working How to display user name? Link to comment Share on other sites More sharing options...
gebeer Posted April 4, 2016 Share Posted April 4, 2016 If 'user' is the name of your page field that holds the users, try <?=$device->user->name?> or <?=$device->user->title?> // if you have a title field in the user template This works only if the user page field is set to hold only one page. 2 Link to comment Share on other sites More sharing options...
chuguruk Posted April 5, 2016 Author Share Posted April 5, 2016 If 'user' is the name of your page field that holds the users, try <?=$device->user->name?> or <?=$device->user->title?> // if you have a title field in the user template This works only if the user page field is set to hold only one page. Yeah, already tried that. Doesn't work. This is my simplified code: <?php $source = $pages->get("/programs/"); $programs = $source->children(); foreach($programs as $program) {?> <tr class="gradeX"> <td><?=$program->title?></td> <td><?=$program->computer?></td> //shows page id <td><?=$program->computer->title?></td> //doesn't show antything <td class="center">4</td> </tr> <?}?> "computer" is a page select field in program template connected to computer page. I can: show computer page id manualy put that id in $computer = pages->get(2893); and echo it's title <?=$computer->title?> I can't: make that automaticIt should be working: <?=$program->computer->title?> but it doesn't show anything. Any ideas? Link to comment Share on other sites More sharing options...
gebeer Posted April 5, 2016 Share Posted April 5, 2016 In the field settings for your computer page field, is this field set to hold multiple pages or a single page? 3 Link to comment Share on other sites More sharing options...
chuguruk Posted April 5, 2016 Author Share Posted April 5, 2016 In the field settings for your computer page field, is this field set to hold multiple pages or a single page? 2016-04-05 15:55:12.png Problem solved! Thank You! Link to comment Share on other sites More sharing options...
gebeer Posted April 5, 2016 Share Posted April 5, 2016 My pleasure. If you set a page field to multiple pages and you only have one value you could get that with <?=$program->computer->first()->title?> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now