Subscribe: RSS
  • Hello community,

    i try to get my pagetitles as single option-values (placeholder) like this:

    <form method="POST" class="form" action="[[~[[*id]]]]">
    <select>
    
        <option>Sport</option>
    
        <option>Cars</option>
    
    </select>
    <input type="submit" value="Send" /></form>
    


    but my snippet put all pagetitle in one row like this:

    <form method="POST" class="form" action="[[~[[*id]]]]">
    <select>
    
        <option>SportCars</option>
    
    </select>
    <input type="submit" value="Send" /></form>
    


    What ist wrong here? Please help.



    My Snippet:

    $collection = $modx->getCollection('modResource',array('template' => 4));
     
    foreach ($collection as $collect){
        $mytitle.=$collect->get('pagetitle');
        $list = "<option>". $mytitle. "</option>";
        $modx->setPlaceholder('list',$list);
    }
    
    return;
    


    HTML Form:

    <form method="POST" class="form" action="[[~[[*id]]]]">
    <select>
    [[+list]]
    </select>
    <input type="submit" value="Send" /></form>
    

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      $collection = $modx->getCollection('modResource',array('template' => 4));
      $list = '';  
      foreach ($collection as $collect){
          $mytitle = $collect->get('pagetitle');
          $list .= "<option>". $mytitle. "</option>";
      }
      $modx->setPlaceholder('list',$list); 
      return;
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • It works great! Thank you Bruno.