Is there any way to made appear my own block in all the pages of moodle?
I´m interested in show the block in all the mods
Thanks
Thanks to Jon's pagelib this is possible. Unfortunately up to now this has only been implemented in the quiz module and the chat module. You can have a look at the code of these modules. Some discussion and some other code examples are here
BTW I really like this new way of handling pages / tables (with the new tablelib and pagelib) Is there anything like this coming for forms as well? It would be nice to be able to add a form in the same manner. It would also make it easier to have a consistent user interface.
Thanks all for your replies,
Both ways are very usefull, maybe the floating toolbar is more simply to implement.
but taking care of my needs (a static main block) into the mods and other extra pages i found this way that i hope be helpfull for you too.
In general terms I create a Theme where the system look in a simply list of files or directories, and if the page that I visit is into this list the main block (or all the blocks designed for the SITE) in the left side is automaticly loaded.
For 1.5 version
I atach you the code in PHP that you must add only in the header.html and footer.html files of your theme directory.
HEADER.HTML (at the Begin of the file)
//Must include the libs of blokcs
require_once($CFG->dirroot .'/lib/blocklib.php');
HEADER.HTML (at the end of the file)
<?php
$CFG->showblock=0;
$inme=me();
//this is the list of files or directories where i want to sho my Blocks
//if you put a directory all the files inside it will show the blocks
$fblocks = array("/calendar/","/mod/","grades.php");
//Here I use a flag to know if I'm in a page or directory of the list
foreach ($fblocks as $fblock){
if(ereg($fblock, me())){
$CFG->showblock=1;
}
}
if($CFG->showblock==1){
//Now I create a table for the main part of the page with two colums, one for the Block
//and other for the really content of the mod
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
echo "<tr><td width=\"120\" valign=\"top\">";
//This is the first colum
//I Include my left Blocks
$PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
$pageblocks = blocks_setup($PAGE);
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
}//This is the second colum for the content of the mod
echo "</td><td valign=\"top\">";
}
?>
<!-- END OF HEADER -->
FOOTER.HTML (at the begin of the file)
<!-- START OF FOOTER -->
<?php
//If I put the Block in this page now I must close the table
if($CFG->showblock==1){
echo "</td></tr></table>";
}
$CFG->showblock=0;
?>
----------------------------- ooooooooo --------------------------
that's all, maybe I'll made a table in the database to customice the list of pages for the block.
If you have some question mail me, in English, spanish or catalan
Thanks all again.