Executar un .php en un block

Executar un .php en un block

per Jon gracia -
Nombre de respostes: 1

Hola,

m'he creat un block i des d'ell executo un fitxer php. Fins aqui cap problema, els resultats son els esperats(es mostren en una nova finestra de l'explorador). Però la meva intenció es que el resultat mostrat pel php es mostri dins un pagina moodle, com passa quan realitzes qualsevol accio amb moodle, que vas aprofundint en la seva estructura.

Us mostro el codi del block:

<?PHP //$Id: block_search_forums.php,v 1.10 2005/05/07 16:25:46 defacer Exp $

class block_cerca extends block_base {
    function init() {
        $this->title = get_string('cerca', 'block_cerca');
        $this->version = 2005030900;
    }

    function get_content() {
        global $CFG;

        if($this->content !== NULL) {
            return $this->content;
        }

        $this->content = new stdClass;
        $this->content->footer = '';

        if (empty($this->instance)) {
            $this->content->text   = '';
            return $this->content;
        }

$project = $CFG->wwwroot.'/../project_Xquery.php';
$this->content->text  = '<FORM ACTION="'.$project.'" METHOD="POST">
<INPUT TYPE="text" NAME="nombre"><BR>
<INPUT TYPE="submit" VALUE="Enviar">
</FORM> ';

        return $this->content;
    }
    function instance_allow_config() {
     return true;
  }
  //permet canviar el titol
  function specialization() {
    $this->title = $this->config->title;
  }
}

?>

Algu em pot ajudar?

Gracies.

En resposta a Jon gracia

Re: Executar un .php en un block

per Ferran M -
Hola Joan,

Potser dic una tonteria i no et serveix, però amb un iframe?
<iframe style="WIDTH: 600px; HEIGHT: 800px" marginwidth="0" marginheight="0" src="bloc_php.php?parametres" frameborder="0" scrolling="no"></iframe>

Encara que penso que la manera més fiable e sseguri la APi de moodle i crear un mòdul, però això requereix molt més temps per conèixer com treballa l'API .

Prova amb l'iframe, potser ja acompleix el teu objectiu.

A reveure

Ferran