We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9549
    • 93 Posts
    As the subject describes, I want to add a function to NewsPublisher which let me choose what folder i want to insert the new document. So, is there some way to get a TV or snippet to list all pagetitles in the site_content table in a a drop menu fashion, select options, in the NewsPublisher Form?

    EDIT: A possible soultion: http://modxcms.com/forums/index.php/topic,10983.0.html
      • 9549
      • 93 Posts
      Anyone?
        • 7455
        • 2,204 Posts
        I hacked a version to let me set a placeholder for the parent ID so that the client could shouse on what day the item was (every day was an own folder it was like a event calender for repeating events.) you could get a snippet to generate a puldownlist I think and combine this with the newpublisher I hacked.

        If you want it let me know, It doe need a small core hack to add a gettv funktion.
          follow me on twitter: @dimmy01
          • 9549
          • 93 Posts
          Thanks Dimmy. However, that seems like overkill for my purposes. I only want a TV or snippet to list all documents in a dropmenu list whose id would later be catched by NewsPublisher. A soultion close at hand would be a TV with @SELECT binding, I think. But I can’t figure out to output it in a drop menu... I think a function like this should be built-in for NewsPublisher! smiley
            • 9549
            • 93 Posts
            I’ve created a piece of code which outputs a drop menu with all folders (containers) in the document tree.
            I’m trying to integrate it to the NewsEditor snippet without success...

            $table = $modx->getFullTableName("site_content");
            $sql_result = $modx->db->select("id, pagetitle, parent", $table, "isfolder = 1", "menuindex DESC");
            
            $category = "0";
            while ($row = mysql_fetch_assoc($sql_result))
            {
            $category = "<option value='".$row['id']."'>".$row['pagetitle']."</option>";
            } 


            Is it possible to insert the results from the loop into a placeholder to use in the template?
              • 7455
              • 2,204 Posts
              thats exectly what I did by hacking the newspublisher so that you can use the id field placeholder like you use conten placeholder and longtitle etc.

                follow me on twitter: @dimmy01
                • 9549
                • 93 Posts
                Cool Dimmy! Sorry for not understand you in the first place. You can PM me or post it here!
                  • 18397
                  • 3,250 Posts
                  Please post it here if you would Dimmy. Thanks smiley
                    • 7455
                    • 2,204 Posts
                    OK, here it is,

                    Now you need to create an input field for the parent id (before this was the &folder parameter that one does not work in this version sorry) so even if you want to have a fixed value you need to create a hidden field in that case.

                    I also have one that also works with tv’s but that one needs a parser core hack. (the linenumbers stated in the hack are changed now so do a search instead)

                    in the TV version search for this part for the required fields check:
                    		if(trim($_POST['pagetitle'])=='') $modx->webAlert('Knop naam mist.');
                    		elseif($_POST['agendatitel']=='') $modx->webAlert('Agenda titel mist.');
                    		elseif($_POST['agendadetail']=='') $modx->webAlert('Korte agendatext mist.');
                    		elseif($_POST[$rtcontent]=='') $modx->webAlert('Content mist..');
                    		elseif($_POST['description']=='') $modx->webAlert('Beschrijving mist.');
                    		elseif($_POST['longtitle']=='') $modx->webAlert('Titel mist.');
                    		elseif($_POST['parent']=='') $modx->webAlert('Activiteit op: dag mist.');
                    		else {
                    



                    Dimmy
                      follow me on twitter: @dimmy01
                      • 9549
                      • 93 Posts
                      Take a look at my code. As you probaly figured out it genereates a drop down menu (as seen in previous post) containting the document tree.
                      This menu pop up when you create new or edit articles. However, when you edit an article I want it’s parent to be selected in the menu.
                      Still with me? smiley I’m totally lost here since I don’t know what if statement is correct.

                      <?php
                      $table = $modx->getFullTableName("site_content");
                      $sql_result = $modx->db->select("id, pagetitle, parent", $table, "isfolder = 1 AND pagetitle <> 'Admin'", "menuindex DESC");
                      
                      
                      if(mysql_num_rows($sql_result)) { 
                      echo "<option value='0'>Huvudmeny</option>";
                      while ($row = mysql_fetch_assoc($sql_result)) {
                      
                      $cid = $row['id'];
                      $pdata = $modx->getParent($cid,1,'id');
                      $pid = $pdata['id'];
                      
                      if($pid == "") { 
                      $pid = "0"; 
                      } 
                      
                      if ($row['id'] == $pid) {
                      $selected = " selected";
                      } else {
                      $selected = ""; 
                      }
                      
                      echo "<option value='".$row['id']."'".$selected."> ".$row['pagetitle']."</option>";
                      } 
                      }
                      else {
                      echo "<option value='0'>Root</option>";
                      }
                      ?>



                      I’m a terrible coder, I know. Nevertheless, I think I’ll publish my reworked version of NewsManager & NewsEditor when it’s finished smiley