{"type":"rich","html":"<div style=\"width: 640; height: 426; font-family: sans-serif,arial,freesans;\" ><div id=\"shared_container_1063914428\" class=\"shared_container\"><div id=\"shared_header_1063914428\" class=\"shared_header\"><a href=\"https:\/\/voidofxulub.com\/channel\/warzazel\"><img src=\"https:\/\/voidofxulub.com\/photo\/profile\/s\/2\" alt=\"\ud835\udd9c\ud835\udd86\ud835\udd97\ud835\udd9f\ud835\udd86\ud835\udd9f\ud835\udd8a\ud835\udd91\u26e7 (Hubzilla)\" height=\"32\" width=\"32\" loading=\"lazy\" \/><\/a><span><a href=\"https:\/\/voidofxulub.com\/channel\/warzazel\">\ud835\udd9c\ud835\udd86\ud835\udd97\ud835\udd9f\ud835\udd86\ud835\udd9f\ud835\udd8a\ud835\udd91\u26e7 (Hubzilla)<\/a>  wrote the following  <a href=\"https:\/\/voidofxulub.com\/item\/d422b309-b838-465f-b245-aa95afc4ee0d\">post <\/a><span class=\"autotime\" title=\"2026-02-26T08:41:10+01:00\">Thu, 26 Feb 2026 08:41:10 +0100<\/span><\/span><\/div><div id=\"reshared-content-1063914428\" class=\"reshared-content\"><strong>Werte aus der Hubzilla-Datenbank im Block anzeigen mit PHP \/&nbsp;&nbsp;Display values from the Hubzilla database in a block using PHP<\/strong><br \/>Man kann sich in Hubzilla mit PHP jeden Wert aus der Datenbank holen, in einem Block ablegen und als Widget auf der Seite anzeigen lassen. Dazu muss die Hubzilla-App <strong>&quot;Webseiten&quot;<\/strong> installiert sein und die App <strong>&quot;PDL Editor&quot;<\/strong>. Dann muss man auf seinem Kanal noch einstellen das Code zugelassen wird. Das aktiviert man unter <strong>Administration - Kan\u00e4le - Checkbox des Kanals anklicken - Code erlauben<\/strong><br \/><br \/>Dann klickt man auf <strong>Webseiten - Bl\u00f6cke - Erstellen - Art des Seiteninhalts - PHP<\/strong><br \/><br \/>Als Blockname vergibt man einen Namen unter dem man den Block sp\u00e4ter im PDL Editor unter Items findet<br \/><br \/><mark class=\"mark\">Translated with DeepL.com (free version)<\/mark><br \/><br \/><blockquote>In Hubzilla, you can use PHP to retrieve any value from the database, store it in a block and display it as a widget on the page. To do this, you need to install the Hubzilla app <strong>&quot;Websites&quot;<\/strong> and the app <strong>&quot;PDL Editor&quot;<\/strong>. Then you have to set your channel to allow code. This can be activated under <strong>Administration - Channels - Click the channel checkbox - Allow code<\/strong><br \/><br \/>Then click on <strong>Websites - Blocks - Create - Type of page content - PHP<\/strong><br \/><br \/>Assign a name to the block that you can later find in the PDL Editor under Items.<br \/><\/blockquote><br \/><a class=\"zrl\" href=\"https:\/\/voidofxulub.com\/photos\/warzazel\/image\/d13c5a54-9102-4026-802d-0e757ae8c9f6\" target=\"_blank\" rel=\"nofollow noopener\"><img class=\"zrl\" style=\"max-width: 100%;\" src=\"https:\/\/voidofxulub.com\/photo\/d13c5a54-9102-4026-802d-0e757ae8c9f6-2.png\" alt=\"Bildschirmfoto vom Blockeditor\" title=\"Bildschirmfoto vom Blockeditor\" loading=\"eager\" \/><\/a><br \/><br \/>Hier der Code zum kopieren:<br \/><br \/><blockquote>Here is the code to copy:<\/blockquote><br \/><pre><code>$host = 'localhost';<br \/>$dbname = 'Name der Datenbank'; \/\/=== Anpassen ===<br \/>$user = 'Name des Datenbankusers'; \/\/=== Anpassen ===<br \/>$password = 'Datenbank-Passwort'; \/\/=== Anpassen ===<br \/><br \/>try {<br \/>$pdo = new PDO(<br \/>&quot;mysql:host=$host;dbname=$dbname;charset=utf8mb4&quot;,<br \/>$user,<br \/>$password,<br \/>[PDO::ATTR_ERRMODE =&gt; PDO::ERRMODE_EXCEPTION]<br \/>);<br \/>} catch (PDOException $e) {<br \/>die('Verbindung fehlgeschlagen: ' . $e-&gt;getMessage());<br \/>}<br \/><br \/>$sql = &quot;SELECT COUNT(*) AS anzahl FROM term WHERE term = :status&quot;;<br \/>$stmt = $pdo-&gt;prepare($sql);<br \/>$status = 'Kategoriename'; \/\/=== Anpassen ===<br \/>$stmt-&gt;bindParam(':status', $status, PDO::PARAM_STR);<br \/>$stmt-&gt;execute();<br \/>$row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);<br \/><br \/>\/\/ ==== Ergebnis ausgeben ====<br \/>echo &quot;Es gibt {$row['anzahl']} Artikel&quot;;<\/code><\/pre><br \/><strong>Anmerkung:<\/strong> Es m\u00fcssen 4 Werte angepasst werden, wichtig ist der &quot;<strong>Kategoriename<\/strong>&quot;, denn die Anzahl derer wird aus der Datenbank zusammengez\u00e4hlt. Ich habe gestern noch keine anderen Werte in der riesigen Tabelle &quot;term&quot; gefunden wo scheinbar wirklich alles drin abgelegt wird woraus sich z.B. die Kategorie Artikel raus ableiten lie\u00dfe.<br \/><br \/>Deswegen ist es wichtig, seinen Artikeln zus\u00e4tzlich einen <strong>einzigartigen<\/strong> Kategorienamen zu geben der garantiert nicht anderweitig benutzt wird. Das sollte aber auch mit allem funktionieren was sich unter Kategorien ablegen l\u00e4sst, z.B. Karten oder normale Posts, weil wie gesagt alles in der Tabelle Term abgelegt wird. Meine &quot;term&quot; hat nach 1 Woche bereits \u00fcber 37.000 Eintr\u00e4ge.<br \/><br \/>Ist das erledigt, geht man in den PDL Editor, w\u00e4hlt unter Modules die Seite aus, auf der der Block angezeigt werden soll, z.B. articles und unter items ist der Block dann zu finden:<br \/><br \/><blockquote>Note: Four values need to be adjusted, the most important being the &quot;category name&quot;, as the number of these is calculated from the database. Yesterday, I couldn't find any other values in the huge &quot;term&quot; table, which seems to contain everything, from which the category &quot;articles&quot; could be derived, for example.<br \/><br \/>That is why it is important to give your articles a unique category name that is guaranteed not to be used elsewhere. However, this should also work with everything that can be stored under categories, e.g. cards or normal posts, because, as I said, everything is stored in the Term table. After one week, my &quot;term&quot; already has over 37,000 entries.<br \/><br \/>Once this is done, go to the PDL Editor, select the page on which the block is to be displayed under Modules, e.g. articles, and the block can then be found under items:<br \/><\/blockquote><br \/><a class=\"zrl\" href=\"https:\/\/voidofxulub.com\/photos\/warzazel\/image\/e6138d03-376d-473f-98b4-89aa76307cb4\" target=\"_blank\" rel=\"nofollow noopener\"><img class=\"zrl\" style=\"max-width: 100%;\" src=\"https:\/\/voidofxulub.com\/photo\/e6138d03-376d-473f-98b4-89aa76307cb4-2.png\" alt=\"Bildschirmfoto des Blocks mit Ausgabe der Anzahl der Artikel\" title=\"Bildschirmfoto des Blocks mit Ausgabe der Anzahl der Artikel\" loading=\"eager\" \/><\/a><br \/><br \/><strong>Wichtig\/Important<\/strong><br \/><span class=\"bookmark-identifier\">#^<\/span><a class=\"zrl bookmark\" href=\"https:\/\/voidofxulub.com\/item\/053efe40-7d7b-4bd4-ace1-f165f8d9ee54\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/voidofxulub.com\/item\/053efe40-7d7b-4bd4-ace1-f165f8d9ee54<\/a><br \/><br \/>#<a class=\"zrl\" href=\"https:\/\/voidofxulub.com\/search?tag=Hubzilla\" target=\"_blank\" rel=\"nofollow noopener\">Hubzilla<\/a> #<a class=\"zrl\" href=\"https:\/\/voidofxulub.com\/search?tag=Datenbank\" target=\"_blank\" rel=\"nofollow noopener\">Datenbank<\/a> #<a class=\"zrl\" href=\"https:\/\/voidofxulub.com\/search?tag=MySQL\" target=\"_blank\" rel=\"nofollow noopener\">MySQL<\/a><\/div><\/div><br \/><\/div>","width":640,"height":426}