1. Dashboard
  2. Articles
  3. Forum
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • More Options
  1. webEdition Forum
  2. Forum
  3. Deutschsprachiges Support Forum
  4. webEdition Templates erstellen (we:tags)

Objekte mit PHP anlegen

  • e-site
  • August 8, 2024 at 1:58 PM
  • e-site
    Student
    Reactions Received
    7
    Posts
    98
    • August 8, 2024 at 1:58 PM
    • #1

    Hallo zusammen,

    ich habe jetzt schon eine Weile diesbezüglich recherchiert und auch Codeschnipsel gefunden. Folgendes funktioniert soweit, das Objekt wird angelegt nur fehlt mir die Zuweisung zur Klasse 'Firmeneintrag' und einer Kategorie ID:

    $obj = new we_contents_objectFile();
    $obj->we_new();
    $obj->IsSearchable = 1;
    $obj->Filename = 'test';
    $obj->Text = 'test';
    $obj->Path = "/Firmeneintrag";
    $obj->setElementS('Firma', 'Testfirma');
    $obj->we_publish();

    Das Objekt 'test' wird angelegt ist allerdings so leer.

    Hat einer einen Tipp? Zuweisung der Klasse und Kategorie?

    Ich weiß, ist nicht updatesicher und sollte mit WE-Tags gemacht werden, nur habe ich nicht die Möglichkeit dazu.

    WE 9.2.3 wird eingesetzt.

    Gruß Heiko

  • WBTMagnum
    Student
    Reactions Received
    11
    Posts
    139
    • August 12, 2024 at 1:58 PM
    • #2

    Hallo Heiko,

    Schau dir mal we_contents_objectFile::initObject() an (sh. https://github.com/dipser/Schnips…hp#L43C5-L49C20

    HTH,
    Sascha

  • e-site
    Student
    Reactions Received
    7
    Posts
    98
    • August 12, 2024 at 2:35 PM
    • #3

    Hallo Sascha,

    danke :thumbup:ich hatte es heute morgen schon hinbekommen.

    Wäre das nichts für die WE-Doku? Müsste natürlich aktualisiert werden.

    Hier zumindest mein Erguss, wichtig war bei der Kategorie das Array! Ich parke das Objekt jetzt zuerst und per Double-Opt-in muss der Eintrag bestätigt werden, damit er veröffentlicht wird.

    $obj = new we_contents_objectFile();
    $obj->we_new();
    $obj->TableID = 1;  //Klassen-ID
    $obj->restoreDefaults();
    $obj->setRootDirID(true);
    $obj->resetParentID();
    $obj->IsSearchable = 1;
    $obj->Filename = $url; //Dateiname
    $obj->Path = "/firmeneintrag/$url";
    $obj->Category = array($branche);
    $obj->setElementS('Url', $url);
    $obj->setElementS('Hash', $hash);
    $obj->setElementS('Firma', $firma);
    .....
    $result = $obj->we_publish();
    $obj->we_unpublish();

    Gruß
    Heiko

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!

Register Yourself Login

Donations

200.00 EUR

Donate now

Tags

  • objekte
  • php

Users Viewing This Thread

  • 1 Guest
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™