We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20413
    • 2,877 Posts
    I have a wish to get my users being able to create weblink-docs and then i output them with wayfinder on a link page.

    Is there a way to create the weblink docs front-end? Can I use the NewsPublisher? smiley

    I guess I will use the FDM or newspublisher and then output a field from the new document as an URL. But it had been soooo sweet
    to create real modx weblink docs.


    SWEEEEEEET --------------> http://modxcms.com/forums/index.php/topic,3242.msg29835.html#msg29835

    I love You MODx!!
      @hawproductions | http://mrhaw.com/

      Infograph: MODX Advanced Install in 7 steps:
      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
      • 20413
      • 2,877 Posts
      I have to share my modified code who zatoichi wrote:
      //replace with the folder id of an unpublished folder to hold the submissions
      $folder = 124; 
      
      $message = <<<MSG
      <p>Submit a link to my public <a href="[~62~]">Web Links</a> page!! : )</p>
      MSG;
      
      $formTpl = <<<FRM
      <form action="[~[*id*]~]" method="POST">
      <input name="linkSubmitted" type="hidden" value="on" />
      <table class="form" border="0" width="100%">
      	<tr>
          <td width="200" class="formLabels"><strong>Site Name</strong>*</td>
      </tr><tr>
          <td><input name="pagetitle" class="form" type="text" size="35" value="$pagetitle" /></td>
        </tr>
          <tr>
          <td width="200" class="formLabels"><strong>Menu Title</strong>* for Link Page</td>
      </tr><tr>
          <td><input name="menutitle" class="form" type="text" size="35" value="$menutitle" /> </td>
        </tr> 
        <tr>
          <td width="200" class="formLabels"><strong>URL</strong>*</td>
      </tr><tr>
          <td><input name="content" class="form" type="text" size="35" value="http://" /> </td>
        </tr>
      	<tr>
          <td width="200" class="formLabels"><strong>SHORT Description</strong></td>
      </tr><tr>
          <td><input class="form" size="35" type="text" name="description" value="$description" /></td>
        </tr>
      	<tr>
          <td width="200" class="formLabels"><strong>Sign ya Name here</strong></td>
      </tr><tr>
          <td><input name="longtitle" class="form" type="text" size="35" value="$longtitle" /> </td>
        </tr> 
      	<tr>
          <td width="200" class="formLabels"></td>
          <td><input type="submit" value="Submit" /> <input type="reset" value="Reset" />
      		</td>
        </tr>   
      </table>
      	</form> 
      FRM;
      
      if (!empty($_POST)) {
      
      		if(get_magic_quotes_gpc()) {
      			$_POST = array_map("stripslashes", $_POST);
      		}	
          
      		$error_border = " style='border:1px solid #cc0000' ";
      		$style = "<span style='color:#cc0000;font-size:11px'>";
      		$end   = "</span>"; 
      				
      		$t = $m = $c = $errormsg = '';
          $t = trim($_POST['pagetitle']);
          $m = trim($_POST['menutitle']);
          $c = trim($_POST['content']);
      		
      		if ($t == '') { 
      		$errormsg .= $style."*Site Name is a required field.<br>".$end; 
      		$error_name = $error_border;
      		}
      
      		if ($m == '') { 
      		$errormsg .= $style."*Menu Title is a required field.<br>".$end; 
      		$error_name = $error_border;
      		}
      		
      		if ($c == '') { 
      		  $errormsg .= $style."*URL is a required field.<br>".$end; 
      			$error_url = $error_border;
      		  $content = "http://";
      		}
      		
      		if ($c == "http://") { 
      		  $errormsg .= $style."*URL is a required field.<br>".$end;
      			$error_url = $error_border; 
      		  $content = "http://";
      		}
      		
      		if (($c != '') and ($c != "http://")) {
      		  $get_host = parse_url($c);
      		  $hostexist = checkdnsrr($get_host[host]);
      		
      		if ($hostexist == FALSE) { 
      		  $errormsg .= $style."*The host, ".$get_host[host].", does not appear valid. Please check the URL.<br>".$end;
      		  $error_url = $error_border;
      			$content = mysql_escape_string($modx->stripTags(trim($_POST['content'])));
      		    }
      	  }
      		
      		if (!empty($errormsg)) {
      		  $pagetitle = mysql_escape_string($modx->stripTags(trim($_POST['pagetitle'])));
      		  $longtitle = mysql_escape_string($modx->stripTags(trim($_POST['longtitle'])));
      		  $description = mysql_escape_string($modx->stripTags(trim($_POST['description'])));
      			
      		
      $formTpl =<<<FRM
      <form action="[~[*id*]~]" method="POST">
      <input name="linkSubmitted" type="hidden" value="on" />
      <table class="form" border="0" width="100%">
      	<tr>
          <td width="200"><strong>Site Name</strong>*</td>
      </tr><tr>
          <td><input $error_name name="pagetitle" type="text" class="form" size="35" value="$pagetitle" /></td>
        </tr>
          <tr>
          <td width="200" class="formLabels"><strong>Menu Title</strong>* for Link Page</td>
      </tr><tr>
          <td><input $error_name name="menutitle" class="form" type="text" size="35" value="$menutitle" /> </td>
        </tr> 
        <tr>
          <td width="200"><strong>URL</strong>*</td>
      </tr><tr>
          <td><input $error_url name="content" type="text" class="form" size="35" value="$content" /> </td>
        </tr>
      	<tr>
          <td width="200"><strong>SHORT Description</strong></td>
      </tr><tr>
          <td><input class="form" size="35" type="text" name="description" value="$description" /></td>
        </tr>
      	<tr>
          <td width="200"><strong>Sign ya Name here</strong></td>
      </tr><tr>
          <td><input name="longtitle" type="text" class="form" size="35" value="$longtitle" /> </td>
        </tr> 
      	<tr>
          <td width="200" class="formLabels"></td>
          <td><input type="submit" value="Submit" /> <input type="reset" value="Reset" />
      		</td>
        </tr>   
      </table>
      	</form> 
      FRM;
      	
      		return $message.$errormsg.$formTpl;
      		}
      
      		$pagetitle = mysql_escape_string($modx->stripTags(trim($_POST['pagetitle'])));
      		$menutitle = mysql_escape_string($modx->stripTags(trim($_POST['menutitle'])));
      		$content = mysql_escape_string($modx->stripTags(trim($_POST['content'])));
      		$longtitle = mysql_escape_string($modx->stripTags(trim($_POST['longtitle'])));
      		$description = mysql_escape_string($modx->stripTags(trim($_POST['description'])));	
          $createdon = time();
      	
      			// post news content
      			$flds = array(
      				'type'        => 'reference',
      				'pagetitle'	  => $pagetitle,
                                      'menutitle'   => $menutitle,
                                      'link_attributes' => 'rel="nofollow" target="_blank"',
      				'longtitle'	  => $longtitle,
      				'description' => $description,
      				'parent'	    => $folder, 
      				'createdon'   => $createdon,
      				'published'   => '1',
      				'deleted' 	  => '0',
      				'hidemenu' 	  => '0',
      				'template' 	  => '0',
      				'content' 	  => $content
      			);
      
      if ($fireinthehole = $modx->db->insert($flds,$modx->getFullTableName('site_content'))) { 
      $message = "<p>Thank you!! : )</p>";
      return $message;
          }    
      } 
      
      if (empty($_POST)) {
      return $message.$formTpl;
      }
      


      See pic!!  cool
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower