Search

Hello together

So I come from textpattern. At the moment i’m learning symphony. and now i ran into the first problems. to output some content such as some artikels works well. but now i want to sort them. in textpattern i does it with a category tree for articels. but here i havent got an idea how to do that. for example with pages and sections? or with a section of categories linked with the articels. What i want is to output a list of «category» links and if i klick on one then the assotiated articels come.

i had searched in the community board and had tested a view things but i doesn’t found the right thing.

so and that’s why i ask now.

i hope anyone had an idea for me - thanks.

Created a page called “Category” or similar, with a URL parameter for categories. Then create a data source that fetches entries from your section and have it filtered by the category parameter passed in the URL.

I understand if this is not detailed enough, but at the moment it’s all I’ve time to write :-)

So you want to have a Categories page that:

  1. Lists all categories and clickable links
  2. Load the page with a category, to see articles under this category

I am assuming that you have two sections: Articles and Categories, and they are linked together using the Select Box Link field.

Create a Data Source (Components > Data Sources) named “All Categories” that pulls from the Categories section. Order these how you wish.

Create a new Page named “Categories” and attach this Data Source to it. When creating the page add “category” as a URL Parameter.

Your Page will need some XSLT along the lines of the following:

    <?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml" />

<xsl:template match="data">
    <html>
        <body>      
            <xsl:choose>
                <!-- category is set, display articles -->
                <xsl:when test="$category != ''">               
                    <h1>Articles in the category: <xsl:value-of select="all-categories/entry[name/@handle = $category]/name"/></h1>
                    <ul>
                        <xsl:apply-templates select="articles/entry"/>
                    </ul>               
                <xsl:when>              
                <!-- category is not set, show category list -->
                <xsl:otherwise>             
                    <h1>Categories</h1>
                    <ul>
                        <xsl:apply-templates select="all-categories/entry"/>
                    </ul>               
                <xsl:otherwise>
            </xsl:choose>       
        </body>
    </html> 
</xsl:template>

<xsl:template match="all-categories/entry">
    <li>
        <a href="/categories/{name/@handle}/">
            <xsl:value-of select="name"/>
        </a>
    </li>   
</xsl:template>

<xsl:template match="articles/entry">
    <li>
        <a href="/article/{title/@handle}/">
            <xsl:value-of select="title"/>
        </a>
    </li>   
</xsl:template>

</xsl:stylesheet>

This will load a list of categories by default. When clicking on a category the page reloads as /category/category-name-here/.

The last step is to create an Articles Data Source that filters its articles on the Category field using the $category URL Parameter.

Hope that puts you in the right direction.

Hi Nick

Thank’s for this nice snipped it worked well. Now I have my categorylist. Now one little question i hav now a page called texte and two sections called texte and categories now if i go on the page texte the linked categories are visible. if i click on one the view changes also but i have some problems with this URL Parameter because in the debug mode alle the articels are visible but in the html output they aren’t. i think the parameter doesen’t work?

Can you post the XML and XSL?

Jep I can

<xsl:template match="data">
    <html>
        <body>      
            <xsl:choose>
                <!-- category is set, display articles -->
                <xsl:when test="$navigation != ''">               
                    <h1>Articles in the category: <xsl:value-of select="dsnavigation/entry[name/@handle = $navigation]/name"/></h1>
                    <ul>
                        gaga<xsl:apply-templates select="dstexte/entry"/>
                    </ul>               
                </xsl:when>              
                <!-- category is not set, show category list -->
                <xsl:otherwise>             
                    <h1>Categories</h1>
                    <ul>
                        <xsl:apply-templates select="dsnavigation/entry"/>
                    </ul>               
                </xsl:otherwise>
            </xsl:choose>       
        </body>
    </html> 
</xsl:template>

<xsl:template match="dsnavigation/entry">
    <li>
        <a href="/blog/{name/@handle}/">
            <xsl:value-of select="name"/>
        </a>
    </li>   
</xsl:template>

<xsl:template match="dstexte/entry">
    <li>
        <a href="/blog/{titel/@handle}/">
            <xsl:value-of select="titel"/>
        </a>
    </li>   
</xsl:template>

xml

<?xml version="1.0" encoding="utf-8" ?>
<data>
    <events />
    <dsnavigation>
        <section id="15" handle="navigation">Navigation</section>
        <entry id="126" navigation="0" texte="1">
            <navigation>
                <item handle="geschaeft" id="125">Geschäft</item>
            </navigation>
            <beschreibung handle="was-koennen-sie-kaufen">Was können Sie kaufen</beschreibung>
            <name handle="angebot">Angebot</name>
        </entry>
        <entry id="125" navigation="1" texte="1">
            <beschreibung handle="meine-firma">Meine Firma</beschreibung>
            <name handle="geschaeft">Geschäft</name>
        </entry>
        <entry id="124" navigation="0" texte="1">
            <navigation>
                <item handle="ich" id="123">Ich</item>
            </navigation>
            <beschreibung handle="alles-ueber-meinen-beruf">Alles über meinen Beruf</beschreibung>
            <name handle="beruf">Beruf</name>
        </entry>
        <entry id="123" navigation="2" texte="1">
            <beschreibung handle="alles-ueber-mich">Alles über mich</beschreibung>
            <name handle="ich">Ich</name>
        </entry>
        <entry id="122" navigation="0" texte="1">
            <navigation>
                <item handle="ich" id="123">Ich</item>
            </navigation>
            <beschreibung handle="alles-ueber-meine-hobbys">Alles über meine Hobbys</beschreibung>
            <name handle="hobbys">Hobbys</name>
        </entry>
    </dsnavigation>
    <dstexte>
        <section id="16" handle="texte">texte</section>
        <entry id="131">
            <navigation>
                <item handle="angebot" id="126">Angebot</item>
            </navigation>
            <inhalt word-count="240">Lieber Kunde und Leser, falls Sie keine Probleme haben, diesen Blindtext schnell und zügig zu lesen, können Sie sich glücklich schätzen. Der verantwortliche Art Director, der Ihnen höchstwahrscheinlich gerade diesen Entwurf präsentiert, versteht sein typografisches Handwerk par excellence.
Er hat diesen Copyblock weder gestaucht, gezerrt, noch in Versalien oder gar in 6 Punkt Eurostile Outline gesetzt. Er hat ihn ganz einfach lesbar gemacht. Offenbar sogar ziemlich gut, sonst hätten Sie wohl schon einige Zeilen zuvor die Leselust verloren.
Beachten Sie nur die Zeilenbreite, die er gewählt hat. Sie ist weder zu lang noch zu kurz gewählt. Der dazugehörige Zeilenabstand ist ideal. Ihre Augen haben keinerlei Probleme, vom Ende einer Zeile in die nächste zu gelangen.
Um einen solchen Art Director kann man Sie beneiden. Er nutzt den ihm gewährten gestalterischen Freiraum nicht, um sich selbst darzustellen, sondern Sie. Er weiß, daß es Wichtiges über Ihr Unternehmen oder Produkt zu sagen gibt.
Und dem räumt er großzügig Platz ein.
Dieser Mensch hat zweifelsohne nicht am Mäschäßutzets Inschtitut of Gräfick Ahts studiert. Er besitzt keine Bücher von Neville Brody oder April Greiman, und wenn doch, ordnet er sie im Regal unter Kunst ein. Statt dessen pflegt er eine liebevoll innige Beziehung zu Büchern von Tschichold und Otl Aicher. Und: Er liest sie.
Sie sollten an dieser Stelle ruhig mal zu ihm rüberlächeln.
Loben Sie ihn.
Laden Sie ihn zum Essen ein.
Denn Sie werden sicher noch viel Freude an seiner Arbeit haben.</inhalt>
            <titel handle="lesbarkeit">Lesbarkeit</titel>
            <ersteller>
                <item id="1" username="dominik">Dominik Rohr</item>
            </ersteller>
        </entry>
        <entry id="130">
            <navigation>
                <item handle="geschaeft" id="125">Geschäft</item>
            </navigation>
            <inhalt word-count="546">Sie erinnern sich. Der Blindtext-Fall im vorigen Jahr. Nun will Karl noch nach Canossa. Und Claudia heiratet zur Busse Copperfield. Jeden Morgen entzünden sie eine Kerze. Jeden Nachmittag ist eine Runde Rosenkranz fällig. Zur Heiligen Marie. Weil Karl mit dem Zopf der Claudia mit dem Smile optisch nette Koran-Typo aufs Mieder hat sticken lassen. Heiliger Blindtext am Busen.
Bumm. Da läßt der Mullah nicht mit sich scherzen. Blindtext killt Chanel, Islam erklärt Karl den Krieg, das Abendland zittert. Der Blindtext-Fall ist geboren. Die Geschichte des Blindtextes und seiner Texter wird aufgeblättert. Endlich. Was wissen Sie über Blindtext? Katholischen nimmt man für Kochbücher, evangelischen für Bauhausmöbelprospekte, hebräischer wird in Hollywood verfilmt, atheistischer ist für Procter & Gamble Waschmittel, arabischer ist nicht. Und weiter? Zu wem beten Karl und Claudia jeden Tag als Buße für ihre Blindtext-Sünde? Zu ihr. Zur Heiligen Marie Antoinette. Madame ging schön aufs Schafott. Welch eine Haltung. Sie weiß, sie kriegt den Kopf ab. Aber vorher pudert sie ihn noch, beißt sich auf die Lippen von wegen Lippenrot, kneift sich in die Wangen von wegen Wangenrot. Und sie weiß, sie wird den Kopf verlieren. Oben ab. Und es stört die Marie nicht. Diese Haltung verehren die Blindtexter. Du weißt, du wirst gecuttet. Aber du gibst alles. Sainte Marie, steh uns bei. The english call it the holy attitude of SM.
Des Blindtexters Heiliges Tier ist das Schwein. Es atmet und furzt, frißt und säuft, um verwurstet zu werden. Wie ähnlich doch dem Blindtext, der nur entsteht, um zerlegt zu werden. Was sagt der Art Director zu Faust? ... denn alles, was entsteht, ist wert, daß es zugrunde geht ...
Lohnt es sich nun zu clustern, was beim Art Direktor hinten rauskommt? Überlassen wir das den Metzgern. So sprechen sie vom Blutwurst-Blindtext, wenn grobe Originalblindtextbrocken in einer ansonsten undefinierbaren Blindtextmasse zu finden sind. Sie sprechen vom Schinken-Blindtext, wenn ein runder geschlossener Blindtext am Stück an einem Foto-Knochen montiert ist. Und es gibt das Blindtext-Filetstück. Das ist der seltene Fall, daß ein Blindtext vom Art Direktor so genommen wird, wie er ist. Psychologen der UCLA, der University of California Los Angeles, haben im Mai dieses Jahres herausgefunden, daß es Art Direktoren gibt, die aufgrund von Geschlecht, Hautfarbe, Religionszugehörigkeit oder Regionalität bisweilen nicht anders können als. Ein Beispiel: Ein männlicher Art Direktor aus Mönchengladbach kann folgendes Stück Blindtext nicht zerhacken: "Borussia ist die beste Fußballmannschaft von allen. Sie ist einfach viel besser als die Schweine-Bayern. Sie spielt elegant und intelligent, frisch und mitreißend. Und Effenberg ist der King."
Der AD aus MG nimmt diesen Blindtext als Filet. Der AD aus München macht daraus Blindtext-Gulasch, wenn nicht -Tatar. Die Geschichte des Blindtextes und seiner Texter ist von Natur aus blutig. Die Blindtexter sind die Heiligen. Ihre Werke werden gemartert. Alle Formen der gepflegten Folter finden Anwendung: Kopf ab, unten ab, rechts ab, links ab, vierteilen, stückeln, in Blöcke hacken, dehnen. Die Art Direktoren sind die Schlächter. Warte, warte nur ein Weilchen, dann kommt Hamann auch zu dir. Wurde gerade mit Schimanski als Art Direktor verfilmt. Pfeifen ADs nicht ständig den Hamann-Song? Wofür steht eigentlich AD? Ist es nicht die MTV-Schreibweise für das schwäbische Tschüs? Die Geschichte des Blindtextes und seiner Texter ist so alt wie die Menschheit, und noch nie konnte sie ganz erzählt werden. Denn irgendwann kommt immer der AD.</inhalt>
            <titel handle="der-blindtext-fall">Der Blindtext-Fall</titel>
            <ersteller>
                <item id="1" username="dominik">Dominik Rohr</item>
            </ersteller>
        </entry>
        <entry id="129">
            <navigation>
                <item handle="beruf" id="124">Beruf</item>
            </navigation>
            <inhalt word-count="283">Weit hinten, hinter den Wortbergen, fern der Länder Vokalien und Konsonantien leben die Blindtexte. Abgeschieden wohnen Sie in Buchstabhausen an der Küste des Semantik, eines großen Sprachozeans. Ein kleines Bächlein namens Duden fließt durch ihren Ort und versorgt sie mit den nötigen Regelialien. Es ist ein paradiesmatisches Land, in dem einem gebratene Satzteile in den Mund fliegen. Nicht einmal von der allmächtigen Interpunktion werden die Blindtexte beherrscht - ein geradezu unorthographisches Leben. Eines Tages aber beschloß eine kleine Zeile Blindtext, ihr Name war Lorem Ipsum, hinaus zu gehen in die weite Grammatik. Der große Oxmox riet ihr davon ab, da es dort wimmele von bösen Kommata, wilden Fragezeichen und hinterhältigen Semikoli, doch das Blindtextchen ließ sich nicht beirren. Es packte seine sieben Versalien, schob sich sein Initial in den Gürtel und machte sich auf den Weg. Als es die ersten Hügel des Kursivgebirges erklommen hatte, warf es einen letzten Blick zurück auf die Skyline seiner Heimatstadt Buchstabhausen, die Headline von Alphabetdorf und die Subline seiner eigenen Straße, der Zeilengasse. Wehmütig lief ihm eine rethorische Frage über die Wange, dann setzte es seinen Weg fort. Unterwegs traf es eine Copy. Die Copy warnte das Blindtextchen, da, wo sie herkäme wäre sie zigmal umgeschrieben worden und alles, was von ihrem Ursprung noch übrig wäre, sei das Wort "und" und das Blindtextchen solle umkehren und wieder in sein eigenes, sicheres Land zurückkehren. Doch alles Gutzureden konnte es nicht überzeugen und so dauerte es nicht lange, bis ihm ein paar heimtückische Werbetexter auflauerten, es mit Longe und Parole betrunken machten und es dann in ihre Agentur schleppten, wo sie es für ihre Projekte wieder und wieder mißbrauchten. Und wenn es nicht umgeschrieben wurde, dann benutzen Sie es immernoch.</inhalt>
            <titel handle="weit-hinter-den-wortbergen">Weit hinter den Wortbergen</titel>
            <ersteller>
                <item id="1" username="dominik">Dominik Rohr</item>
            </ersteller>
        </entry>
        <entry id="128">
            <navigation>
                <item handle="hobbys" id="122">Hobbys</item>
            </navigation>
            <inhalt word-count="170">Ja, wir finden auch, dass man über die Copy noch mal reden sollte. Das hier kann es jedenfalls nicht sein. Das klingt ja wie auf dem Totenbett getextet. Da muss wesentlich mehr Produktaussage rein. Ja, wir finden auch, dass man über die Copy noch mal reden sollte. Das hier kann es jedenfalls nicht sein. Das klingt ja wie auf dem Totenbett getextet. Da muss wesentlich mehr Produktaussage rein. Ja, wir finden auch, dass man über die Copy noch mal reden sollte. Das hier kann es jedenfalls nicht sein. Das klingt ja wie auf dem Totenbett getextet. Da muss wesentlich mehr Produktaussage rein. Ja, wir finden auch, dass man über die Copy noch mal reden sollte. Das hier kann es jedenfalls nicht sein. Das klingt ja wie auf dem Totenbett getextet. Da muss wesentlich mehr Produktaussage rein. Ja, wir finden auch, dass man über die Copy noch mal reden sollte. Das hier kann es jedenfalls nicht sein. Das klingt ja wie auf dem Totenbett getextet. Da muss wesentlich mehr Produktaussage rein.</inhalt>
            <titel handle="produkt-aussage">Produkt-Aussage</titel>
            <ersteller>
                <item id="1" username="dominik">Dominik Rohr</item>
            </ersteller>
        </entry>
        <entry id="127">
            <navigation>
                <item handle="ich" id="123">Ich</item>
            </navigation>
            <inhalt word-count="185">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.</inhalt>
            <titel handle="lorem-ipsum-dolor">Lorem ipsum dolor</titel>
            <ersteller>
                <item id="1" username="dominik">Dominik Rohr</item>
            </ersteller>
        </entry>
    </dstexte>
</data>
  1. you’ve got a URL param for your page called ‘navigation’?
  2. you’re passing the category name with that URL param?
  3. if so, do you see any of the other output? the h1 or the ul or the “gaga” text?

Hi

So i see the gaga text :-) that’s why i write that. If you want to see the dummy page got to

http://fp.bleed.ch/blog

I had the param for my page called navigation and the categoryname come also in the url list.

There’s an XSLT error on that page right now. Looks like an unescaped ampersand somewhere.

Jups i know jet i have $navigation in the «Required URL Parameter» of dstexte an then the error come if you go into a category.

and if i put the $navigation param into Filter Results Filter … by and filter the Select box Link by this value every thing work expect that no articels come.

So your blog page has as its URL Parameter navigation?

yes that’s right. This param is also listet in the debug page http://fp.bleed.ch/blog/?debug=params if i go to a category. then the parameter has also a value.

So one error i had found and now the articels where displayes but this sort thing does not work. All articles come and the url parameter for sorting were ignored.

I am trying something similar on a modified version of the default theme using nickdunn’s work in the 3rd comment. But I can’t get it to work completely. I get the categories list to show, but when I click through to the articles per category I get an empty list. When I delete {@category} from Filter Results I do get a result, but obviously I get all the articles. In the Debug screen the parameter $category seems to be correctly declared. I tried to filter on other fields (publish) and that works. Could this be because categories is a Select Box Link?

Your filter should not be {@category} but {$category} — could that be it?

In the Debug screen the parameter $category seems to be correctly declared

Could you elaborate on this please?

Could this be because categories is a Select Box Link?

Yes, this could be the problem. Let’s say you have a page Categories, and you pass the category handle on the end of the URL (so the Categories page has a URL Parameter named category). When you do this, the param list should have a param named $category with this handle value.

You will only be able to filter Articles by this category handle if Categories are linked to an article using a Select Box, because the Select Box field joins on the string value itself.

If you’re using a Select Box Link then you will need to filter the Articles section by the ID of the selected category. In order to do this you will need to modify your “All Categories” Data Source. Add a filter to this DS such that it filters the category name/title using the {$category} parameter. So when you add a category name to the URL only the chosen category is in the XML.

Then at the bottom left of the DS editor choose “System ID” from the Output parameters list. Then refresh the params list for your page. You should see a new param in the list named $ds-all-categories (if your DS is called “All Categories”) which contains the internal ID of the category entry.

You can then filter the category Select Box Link in your Article DS by this {$ds-all-categories} value.

In summary: if you link entries using a Select Box Link field you will need to filter by the linked entry IDs, and not their handles. Therefore you can use the “output parameters” from a DS that filters on handles, to then filter another DS by IDs.

Hope that makes sense!

That did it Nick! Thank you a lot. I think you might need one of those ‘buy me a beer’-buttons on your website! Though for someone like you, that might be a bit unhealthy…

In response to your questions: {@category} is a typo I only made on these forums. With “In the Debug screen the parameter $category seems to be correctly declared” I meant that under PARAMS on the debug screen I could see a parameter called category with the handle value I was expecting.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details