<?xml version="1.0" encoding="iso-8859-15"?>
<!-- generator="Kukkaisvoima version 9-pr0.1" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel>
<title>datensal.at: Code</title>
<link>http://datensal.at/index.cgi</link>
<description>Jee</description>
<pubDate>Sat, 18 Oct 2008 13:03:08 +0200</pubDate>
<lastBuildDate>Sat, 18 Oct 2008 13:03:08 +0200</lastBuildDate>
<generator>http://23.fi/kukkaisvoima/</generator>
<language>en</language>
<item>
<title>Drupal Kategorien mit Anzahl enthaltener Artikel als Liste ausgeben
</title>
<link>http://datensal.at/index.cgi/drupalkategorien%3A2008-10-18%3ACode%2CSoftware%2CWeblog</link>
<comments>http://datensal.at/index.cgi/drupalkategorien%3A2008-10-18%3ACode%2CSoftware%2CWeblog#comments</comments>
<pubDate>Sat, 18 Oct 2008 13:03:08 +0200</pubDate>
<dc:creator>Juergen</dc:creator>
<category>Code</category>
<category>Software</category>
<category>Weblog</category>
<guid isPermaLink="false">http://datensal.at/index.cgi/drupalkategorien%3A2008-10-18%3ACode%2CSoftware%2CWeblog/</guid>
<description><![CDATA[ 
 [...]]]></description>
<content:encoded><![CDATA[

<div align="justify">Weblogs bestehen f&uuml;r gew&ouml;hnlich, unabh&auml;ngig von ihrem durch verschiendenste Templates angepassten Layout, aus folgenden grundlegenden Komponenten: Einem Hauptmen&uuml; mit der groben Struktur des Weblogs (Home, Impressum, Kontakt etc.), der Kategorienliste, dem Archiv, eventuell einer Tag-Cloud und nat&uuml;rlich dem Hauptbereich, in dem die Artikel gelistet werden. Bei expliziter Blog-Software wie <a href="http://www.wordpress.org/" target="_blank">Wordpress</a> oder <a href="http://s9y.org/" target="_blank">Serendipity</a> mu&szlig; man sich um das Vorhandensein bzw. die Darstellung dieser Komponenten in der Regel keine Sorgen machen. 
<p><a href="http://drupal.org" target="_blank">Drupal</a> ist jedoch ein ausgewachsenes Content Management System (CMS), mit einer ganz eigenen Philosophie bez&uuml;glich der Strukturierung und Organisation. Das sogenannte <a href="http://drupal.org/node/299" target="_blank">Taxonomie</a>-System ist ein m&auml;chtiges, zentrales Konstrukt, das schier unbegrenzte Flexibilit&auml;t gew&auml;hrleistet. Auch ein Weblog l&auml;sst sich mit Drupal relativ einfach durch das Aktivieren eines Moduls realisieren. Jedoch fehlt zun&auml;chst die M&ouml;glichkeit, mit einem Klick einen Block ins Layout zu zaubern, der die definierten Kategorien ausgibt. Hierzu liefert aber das Taxonomie-System die n&ouml;tige Funktionalit&auml;t. </p>
<p>Mit Hilfe des <a href="http://www.tobiasbaehr.de/artikel/wie-kann-ich-eine-einfache-liste-der-begriffe-eines-vokabulars-ausgeben" target="_blank">Mini-Tutorials</a> von Tobias B&auml;hr, habe ich mir zun&auml;chst eine Liste meines Kategorien-Vokabulars erstellen lassen. Da ich noch die Anzahl der mit der jeweiligen Kategorie verkn&uuml;pften Artikel ausgeben lassen wollte, habe ich Tobias' Code-Snippet noch um die Funktion <a href="http://api.drupal.org/api/function/taxonomy_term_count_nodes/6" target="_blank"><strong>taxonomy_term_count_nodes($tid)</strong></a> erg&auml;nzt:<br />
<div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$vid</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span>; <span style="color: #666666; font-style: italic;">/* &lt;---- hier kommt die Vokabular-ID hin */</span>
<span style="color: #000088;">$terms</span> <span style="color: #339933;">=</span> taxonomy_get_tree<span style="color: #009900;">&#40;</span><span style="color: #000088;">$vid</span><span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">print</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span>;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$terms</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$term</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">print</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span><span style="color: #339933;">.</span>l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$term</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span><span style="">'taxonomy/term/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$term</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tid</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$term</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (&quot;</span><span style="color: #339933;">.</span>taxonomy_term_count_nodes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$term</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)&lt;/li&gt;&quot;</span>;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">/* end foreach */</span>
<span style="color: #990000;">print</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div><br />
Fertig ist die Kategorienliste mit Artikelanzahl.
</p></div><br/> ]]></content:encoded>
<wfw:commentRss>http://datensal.at/index.cgi/drupalkategorien%3A2008-10-18%3ACode%2CSoftware%2CWeblog/feed/</wfw:commentRss>
</item>
</channel>
</rss>
