Jump to content

coderenaline

Members
  • Posts

    6
  • Joined

  • Last visited

coderenaline's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. added this code with ___sleepValue() to the first posting. I expected so an DB entry with predefined values but .... nothing. Why? /** * Konvertiert die Daten des Fieldtyps in ein Array wie es für die DB benötigt wird * nach dem Muster: $kcValue[] = array('data' => "111", 'info1' => "Testeintrag", 'info2' => "Testeintrag 2"); */ public function ___sleepValue(Page $page, Field $field, $value) { $kcValue = array(); $kcValue[] = array('data' => "111", 'info1' => "Testeintrag", 'info2' => "Testeintrag 2"); return $kcValue; } Could it be possible that i need an DataWire-Object with set()-method?
  2. Hello, i would like write a module with a simple textfield (for learning). I had this actually, but all my input in the textfield dont be stored in db or is displayed in my textfield after safe. What ist wrong or is missed? Thx. <?php class FieldtypeTest extends FieldtypeMulti { /** * - Zwingend notwendig * Angaben zum Modul in PW */ public static function getModuleInfo() { return array( 'title' => 'Beispielmodul für Eigenentwicklungen', 'version' => 1, 'summary' => 'Einfache Texteingabe als Beispiel für eigene Module.', 'requires' => '', ); } /** * - Zwingend notwendig * alles hierin wird garantiert jedesmal ausgeführt */ public function init() { parent::init(); } /** * Gibt das Datenbankschema für diesen Feldtyp an * bei vollkommen PW untypischen Tabellenstrukturen wäre die Tabellenerstellung in der Methode ___install() möglich */ public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); // 'data' is a required field for any Fieldtype, and we're using it to represent our 'date' field $schema['data'] = 'INT NOT NULL DEFAULT 0'; // our text fields $schema['info1'] = 'TINYTEXT NOT NULL'; $schema['info2'] = 'TEXT NOT NULL'; return $schema; } /** * Gibt das zugehörige Eingabefeld * $page und $field kommen von PW (noch nicht genau erörtert woher genau) * $field ist in der Basisversion die ID in der DB-Tabelle "fields" * */ public function getInputfield(Page $page, Field $field) { $inputField = $this->modules->get('InputfieldTest'); return $inputField; } } and this: <?php class InputfieldTest extends Inputfield { public static function getModuleInfo() { return array( 'title' => 'Inputfeld für das FieldtypeTest', 'version' => 1, 'summary' => 'siehe FieldtypeTest', 'requires' => 'FieldtypeTest', ); } /** * - Zwingend notwendig für ein Inputfeld * Erzeugt/Liefert die Ausgabe des Inputfeldes */ public function ___render() { $out = "Irgendwelcher Output"; // Erzeugt ein Textfeld $input1 = $this->modules->get('InputfieldText'); $input1->attr('id', $this->attr('name') . "_info1"); $input1->attr('name', "_info1"); $input1->class .= " InputfieldInfo1"; $input1->value = $this->value; $out .= $input1->render(); return $out; } public function init() { parent::init(); } }
  3. Ok, in the hookable method "___sleepValue()" in FieldtypeEvents.module.php in line 110 ive found: $value->sort('date'); One questions is answered. Not 100% understand all the code but one big step further.
  4. Hello. Yes, this: https://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/ This example sorts after date with the db column "sort". I couldnt see where the content of the db-column "sort" is defined. Now im searching for sleepValue() and wakeupValue() in the code. By the way, i'm german too.
  5. I dont understand the "event" example from ryan. Where are the methodes for set and get the variables from the db? How can i write own modules without understanding this basics? Thx
  6. I dont be an pro coder, but understand all what i want to know so far. Now i try to understand the code from processwire. Espacially how PW does get and set data in the database. I look Database....php, WireData.php and so on and many set() and get()-methods therein. And i know of the existence from $db. But i dont understand or see which method(s) in which class(es) used for SQL-Statements - especially in the case of fields. So i look the code from the example "event" from ryan. I see set() and get()-methods in event.php. Can anyone help me and hands on me further? Which methods and classes set and get data from the database? How can i manipulate the sort-order? Thank in advance. I know how i can wrote and read in the DB with the $db, but i would like understand the processwire-way.
×
×
  • Create New...