What I did:
1. added content, longtitle to the $fields variable
2. added a check to see if the type is "reference" (weblink) or regular document
3. in the document edit area in the manager, when editing or creating a weblink, the longtitle is used for the target attribute in the link - if you leave the longtitle blank it willl default and stay in the current window.
longtitle example: target='_blank'
/* Â
MenuBuilder
  1/05/06
  support for weblinks opening in a new window
 added:  content, longtitle to the $fields variable
     now in the document area of the manager, when you create a weblink
     the longtitle setting is where you need to add the target
    example:  target='_blank'
    I also removed the [~ ~] from the weblink part of the link code
*/
$id = isset($id) ? $id : $etomite->documentIdentifier;
$sortby = "menuindex";
$sortdir = "ASC";
$fields = "id, type, pagetitle, description, parent, alias, content, longtitle";
$indentString="";
if(!isset($indent)) {
  $indent = "";
  $indentString .= "";
} else {
  for($in=0; $in<$indent; $in++) {
    $indentString .= " ";
  }
  $indentString .= "» ";
}
$children = $etomite->getActiveChildren($id, $sortby, $sortdir, $fields);
$menu = "";
$childrenCount = count($children);
$active="";
if($children==false) {
  return false;
}
for($x=0; $x<$childrenCount; $x++) {
    if($children[$x]['id']==$etomite->documentIdentifier) {
        $active="class='highLight'";
    } else {
        $active="";
    }
// This is the area which checks to see if the
// document is a type "reference" (weblink) then
// checks whether the document longtitle setting is empty
// (that is where you add your target)
if($children[$x]['type'] == 'reference') Â {
    if($children[$x]['longtitle'] !=''){
     $target = $children[$x]['longtitle'];
     }else{
     $target ="";
     }
  if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
        $menu .= "<a ".$active." href='".$children[$x]['content']."' ".$target.">$indentString".$children[$x]['pagetitle']."</a><br>[[MenuBuilder?id=".$children[$x]['id']."&indent=2]]";
    } else {
        $menu .= "<a href='".$children[$x]['content']."' ".$target.">$indentString".$children[$x]['pagetitle']."</a><br>";
    }
}else{
// this is a regular internal link
    if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
        $menu .= "<a ".$active." href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a><br>[[MenuBuilder?id=".$children[$x]['id']."&indent=2]]";
    } else {
        $menu .= "<a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a><br>";
    }
} // end else
}
return $menu."";
hopefully some of the other snippet authors can use this code and make their snippets weblinkable too... :betterwink:
Edited by breezer, 07 January 2006 - 06:56 AM.











