Buenos Días
Intentare explicar mi problema lo mejor posible, necesito acceder al valor de las variables $COURSE->id, $USER->id; cuando las llamo desde el archivo header.html no tengo ningun problema, pero cuando las llamo desde el contenido de mooodle no logro obtener ningun resultado, mi idea es crear un recurso de pagina web, hacer vinculos al chat, foro, blog y enviarles por parametros estos valores al chat y al foro, los vinculos q estoy utilizando son
<a href="<?php echo $CFG->wwwroot.'/mod/chat/index.php?id='.$COURSE->id?>">CHAT</a>
gracias
Ambas son variables de ambito global, si no recuerdo mal, y por tanto tienes que declararlas como tales en algún momento. Es decir, tienes que usar la directiva "global".
Usando el mismo ejemplo:
<a href="
<?php
global $COURSE;
echo $CFG->wwwroot.'/mod/chat/index.php?id='.COURSE->id;
?>
">CHAT</a>
Usando el mismo ejemplo:
<a href="
<?php
global $COURSE;
echo $CFG->wwwroot.'/mod/chat/index.php?id='.COURSE->id;
?>
">CHAT</a>
Hola Xavier, gracias por responder, lo intente utilizando la solución que planteas y no logro que funcione, no se porque razón sucede esto, ya que por ejemplo con $CFG funciona, pero con $USER o $COURSE no, tu con tus conocimientos me podrías ayudar, será que me hace falta llamar alguna libreria para que esto funcione.
¿Puedes poner parte del código? Eso podría ayudar a detectar el problema...
envió el codigo que estoy utilizando,este codigo lo estoy incluyendo en un recurso dentro del curso, pero como te cuento no toma las variables globales
<?php
global $COURSE;
global $USER;
//$COURSE->id
//echo $USER->id;
//print_r($USER);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="100"> </td>
<td width="46%"><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/mod/chat/index.php?id='.$COURSE->id?>" target="_parent">
<img src="images/chat.jpg" border="0" /></a></td>
<td width="32%"> </td>
</tr>
<tr>
<td height="100"> </td>
<td><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/mod/forum/index.php?id='.$COURSE->id?>" target="_parent"><img src="images/foro.jpg" border="0" /></a></td>
<td> </td>
</tr>
<tr>
<td height="100"> </td>
<td><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/blog/index.php?userid=7&courseid='.$COURSE->id?>" target="_parent"><img src="images/blog.jpg" border="0" /></a></td>
<td> </td>
</tr>
</table>
<?php
global $COURSE;
global $USER;
//$COURSE->id
//echo $USER->id;
//print_r($USER);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="100"> </td>
<td width="46%"><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/mod/chat/index.php?id='.$COURSE->id?>" target="_parent">
<img src="images/chat.jpg" border="0" /></a></td>
<td width="32%"> </td>
</tr>
<tr>
<td height="100"> </td>
<td><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/mod/forum/index.php?id='.$COURSE->id?>" target="_parent"><img src="images/foro.jpg" border="0" /></a></td>
<td> </td>
</tr>
<tr>
<td height="100"> </td>
<td><a href="<?php echo $CFG->wwwroot.'/moodle/moodle/blog/index.php?userid=7&courseid='.$COURSE->id?>" target="_parent"><img src="images/blog.jpg" border="0" /></a></td>
<td> </td>
</tr>
</table>