Jump to content

test123

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by test123

  1. Hi Tomo83 and welcome to PW.

    I think you just want:

    $player->playername

    You are looking for the value of the field "playername" on the page that is referenced by the variable $player.

    If you use:

    $player->fields->get("playername") 

    you'd actually most likely be looking for things like:

    $player->fields->get("playername")->label

    or:

    $player->fields->get("playername")->description

    Hi adrian,

    ok it was that simple... :-)

    $player->playername

    did the job. Thank you!

    • Like 1
  2. Hi everyone,

    I am new to ProcessWire and have an question about the methods get field values.

    First of all my page setup:

    I have a page as a child of the Admin page which is named Data. The idea is to create all my data objects as children of this page. So the data page and all of its children should never be seen on the front-end. Every page uses the same template. The template has one field named playername of type Text.

    Now I am looping through all pages which are children of the Data page in this way (The page id is 1011):

    //get the data-page
        $datapage = $pages->get(1011);
        
        //get all children from data-page
        $players = $datapage->children();
        
        //loop through the children
        foreach($players as $player) {
            $field = $player->fields->get("playername");
            echo $player->title . " " . $field . "<br> ";
        }

    The problem now is, that I don't get the value of the field playername. Instead the output of $field is "playername". Why am I getting the field name instead of the fieldvalue. I am expecting to get the string, which is entered in the playername-field and not the name.

    Hope anybody can help me and big thanks in advance!

×
×
  • Create New...