$this->content->text (add HTML)?

Re: $this->content->text (add HTML)?

by Franco Pantoja -
Number of replies: 3
Picture of Particularly helpful Moodlers

Hi

content->text make an array to be rendered in html, just indicate the html text in the string, eg.

$this->content->text .= "\n<ul class='inline-list'>\n";

 Pay attention to indicate .= to add new values.


Don't forget the latest Moodle version improve the logic and use  $this->content->items[], that accept as well an array of (html) string

$this->content->items[]='<hr></hr><p><a href="'.$CFG->wwwroot.'/course/edit.php?id='.$id.'"><i id="icon" class="fa fa-pencil"></i> '.get_string('edit','block_advanced_course').'</a></p>';


Regards!!

Average of ratings: Useful (2)
In reply to Franco Pantoja

Re: $this->content->text (add HTML)?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Just one query Paco - is content->text an array?

the .= operator is a concatenation string operator rather than adding new values to an array isn't it? And the output is actually a single string, rather than a series of values in an array I believe.

Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: $this->content->text (add HTML)?

by Franco Pantoja -
Picture of Particularly helpful Moodlers

Thanks Richard !!

your right, 

I didn't mean exactly what I was thinking


Regards!!

Average of ratings: Useful (1)
In reply to Franco Pantoja

Re: $this->content->text (add HTML)?

by Carlos Zurera Andrés -

Ohhh!! thank u so much for your answers! I don't understand very well ... I have this code and I want to put inside the content of the block:


-----------------------------------------

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>demo</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="author" content="Me">
  <!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->

  <style>
  .buttons{
   margin-top: 50px;
   overflow: hidden;
  }

  a:focus, input:focus{
   border: 5px solid red;
  }

  input:focus+label{
   color: #f00;
  }

  div:focus{
   border: none;
  }


  
  .btn{
   padding: 20px;
   float: left;
   text-align: center;
   background: #ccc;
   margin: 10px;
   color: #fff;
   cursor: pointer;

   -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
  }

  </style>
</head>
<body>

 <div>
  <a href="http://google.com" target="_blank">Enlace 1</a>
 </div>
 <div>
  <label for="c01">Campo 1</label>
  <input type="text" id="c01"/>
 </div>

 <div>
  <label for="c02">Campo 2</label>
  <input type="text" id="c02"/>
 </div>

 <div>
  <input type="checkbox" id="c03"/>
  <label for="c03">Campo 3</label> 
 </div>
 

 <div class="buttons">

  <div id="nextButton"  class="btn">
  SIGUIENTE
  </div>

  <div id="clickButton" class="btn">
   CLICK
  </div>

  <div id="ZURE" class="btn" onclick="alert('A VER SI NOS TOMAMOS UNAS BIRRAS!');">
   BOTON ESPECIAL PARA ZURE
  </div>
 </div>

  
<script type="text/javascript" src="//code.jquery.com/jquery-1.7.2.min.js"></script>
  <script src="main.js"></script>
</body>
</HTML>

---------------------------------------------------------

I tried to put this code in a HTML block but it is not possible with jquery and the other js file. For that reason I created a new custom block. Can I put the full of this code in any way? Im so sorry for my small knowledge... :/