How can I add an external url into a category to left_nav.php?

Hi community!, I´m trying to insert an external URL into a category using the left_nav.php file, I tried the next way:

But this doesn´t work correctly, I have the next error when I tried to open the category :

Exist a way to add an external URL into the primary_docs array?

Best regards.

@Saul_Romero,

You can add custom links by customizing the OpenEMR codes.
Please refer the attached screen to add custom links in left_nav.php.

changes in left nav.php -> ( loadFrame2 ) function :

function loadFrame2(fname, frame, url,iscustom=false) {

if(iscustom){

  var f = document.forms[0];
	if(f.sel_frame)
   {
	  var fi = f.sel_frame.selectedIndex;
	  if (fi == 1) frame = 'RTop'; else if (fi == 2) frame = 'RBot';
   }
  if (!f.cb_bot.checked) frame = 'RTop'; else if (!f.cb_top.checked) frame = 'RBot';
  top.frames[frame].location =  url;

}
else{
	
  var usage = fname.substring(3);
  if (active_pid == 0 && usage > '0') {
   alert('<?php xl('You must first select or add a patient.','e') ?>');
   return false;
  }
  if (active_encounter == 0 && usage > '1') {
   alert('<?php xl('You must first select or create an encounter.','e') ?>');
   return false;
  }
  if (encounter_locked && usage > '1') {
   alert('<?php echo xls('This encounter is locked. No new forms can be added.') ?>');
   return false;
  }
  var f = document.forms[0];
  top.restoreSession();
  var i = url.indexOf('{PID}');
  if (i >= 0) url = url.substring(0,i) + active_pid + url.substring(i+5);
  if(f.sel_frame)
   {
	  var fi = f.sel_frame.selectedIndex;
	  if (fi == 1) frame = 'RTop'; else if (fi == 2) frame = 'RBot';
   }
  if (!f.cb_bot.checked) frame = 'RTop'; else if (!f.cb_top.checked) frame = 'RBot';
  top.frames[frame].location = '<?php echo "$web_root/interface/" ?>'+ url;
  if (frame == 'RTop') topName = fname; else botName = fname;
  return false;
}
 }
  1. adding custom links:

2)changes in greenTreelink function :

Kindly check this and let us know if you have any clarifications .

Thanks,
ViSolve

2 Likes

Thanks for your anwser @visolveemr , I have added the changes that you provided me and I can add the custome link : Custom

However I have the same problem when I tried to open the external URL( I use your URL in my example) :

Regards.

Hi.
It’s seem you need to do changes also in the genTreeLink function… you need to add there parameter ‘iscustom’ like loadFrame2 funtion.

// Helper functions for treeview generation.
function genTreeLink($frame, $name, $title, $mono = false, $iscustom=false )
{
    global $primary_docs, $disallowed;
    if (empty($disallowed[$name])) {
        $id = $name . $primary_docs[$name][1];
        echo "<li><a href='' id='$id' onclick=\"";
        if ($mono) {
            if ($frame == 'RTop') {
                echo "forceSpec(true,false);";
            } else {
                echo "forceSpec(false,true);";
            }
        }

        echo "return loadFrame2('$id','$frame','" .
            $primary_docs[$name][2] . "',$iscustom)\">" . $title . ($name == 'msg' ? ' <span id="reminderCountSpan" class="bold"></span>' : '')."</a></li>";
    }
}

Try it…

If you want to put your new link in the category of modules or report I can help you to create new module that redirects to external url. this better if you plan to upgrade your project in the future.

Amiel

2 Likes

Skeleton of ZF2 module for OpenEMR.
If someone else need…

1 Like

Hi @Amiel ,

Thanks for contributing this module skeleton. This may be a really good thing for OpenEMR to bring into the main github repos (would basically bring it in as a separate repo) at OpenEMR · GitHub if you agree @Amiel . Thoughts on me doing this @robert.down ?

thanks,
-brady

Hi @brady.miller,

Of course you can take it.