Maybe you want to have a look at my emptyTestBlock Code I published here:
http://dev.moodle.org/course/view.php?id=2$
to show how a Block works/has to be programmed (you have to search for emptyTestBlock in the Forums there). This will give you a sense for SERVER-SIDE code. Which means that a program is executed on the server directly gathering all needed data from its database. The Server and the program, i.e. php-script has to RENDER the gathered Data and then send it to the clients' internet browser for display. Gathering Data and Rendering are typical serverside-tasks.
On the other end, you have your internet-browser working as CLIENT, as opposed to the SERVER on the other end of the line. Fortunately or strangely, you can even program your internet-browser to execute program-code on its side. Typically you use a programming language called JavaScript.
There are many online web-sites to show/teach you how to program with JavaScript. If your Server sends such JavaScript to the internet-browser, that code can be executed locally on the users' computer, e.g. when the user clicks a button or a link.
Your serverside php-program can not only gather data and send HTML-formatted Text to be displayed on a client, it can also compose JavaScript, i.e. a program or many many functions to be used and executed on the client.
Please click on my sitenavigation to show up in a popUp window here:
https://moodle.fhnw.ch/moodleTest/
And if you inspect the HTML- and JavaScript-Code I composed on the Moodle server with php, you will see, that I sent the client a function to open that popUp-window. It is actually this JavaScript-construct that opens the popUp-Window:
<a title="sitenavigation: Show in a Pop-Up-Window" onclick="this.target='popup'; return openpopup('/file.php/1/sess_48pVxxCvLL_sitenavigation.html', 'sitenavigationPopUp', 'menubar,toolbar,location,status,scrollbars,resizable,width=1024,height=768', 0);" href="https://moodle.fhnw.ch/moodleTest/1/sess_48pVxxCvLL_sitenavigation.html" target="sitenavigationPopUp">
And this is how I programmed my Block to display/render/send the above line to the client browser:
$this->sitenavigationcontent->text = '<a title="' . get_string('showinpopupwindow','block_sitenavigation') .
'" href="' . $CFG->wwwroot . $sitenavigationfile .
'" target="sitenavigationPopUp" '.
"onclick=\"this.target='popup'; ".
"return openpopup('/file.php" . $sitenavigationfile ."', 'sitenavigationPopUp', ".
"'menubar,toolbar,location,status,scrollbars,resizable,width=1024,height=768', 0);\">" .
get_string('showinpopupwindow','block_sitenavigation') . "</a>";
To be honest, openpopup() was programmed by the Moodle Core Programmers. So I did not invent/program it. I actually only prepared everything so that when the link is clicked on, the function gets called to show the data I gathered on the server and that should be displayed in the popUp-window. But you could also invent/program your own JavaScript Code/functions and send them to your clients. This is how the Moodle Programmers did it in one of their libraries and how it gets transferred to the client browser:
342 <script type=\"text/javascript\">
343 <!--
344 function openpopup(url,name,options,fullscreen) {
345 fullurl = \"".$CFG->httpswwwroot."\" + url;
346 windowobj = window.open(fullurl,name,options);
347 if (fullscreen) {
348 windowobj.moveTo(0,0);
349 windowobj.resizeTo(screen.availWidth,screen.availHeight);
350 }
351 windowobj.focus();
352 return false;
353 }
354
355 </script>";
Rosario