mazedigital / association_output

Association Output for Symphony: Inline XML
MIT License
5 stars 4 forks source link

Associated content select in Datasource not reflected #6

Closed animaux closed 10 years ago

animaux commented 10 years ago

Ich schreib mal in Deutsch …

Habe eine Datenquelle mit einem Association-Feld, und egal welches Feld daraus ich auswähle, es wird immer nur das Reflection Field ausgegeben (vorschau).

Ausgewählt ist beschreibung:

bildschirmfoto 2014-08-14 um 14 17 26

Raus kommt aber der Inhalt von vorschau.

bildschirmfoto 2014-08-14 um 14 18 30

Egal ob ich eine oder mehrere der Felder unter »Bilder« auswähle.

nilshoerrmann commented 10 years ago

Das ist die Installation, bei der Du den SSM aktualisiert hast oder?

animaux commented 10 years ago

Ich habe noch eine andere Datenquelle mit dem gleichen Problem und eine die funktioniert. Der Unterschied der beide ist, dass die nicht funktioinierenden eine gruppierte Ausgabe haben. Schätze das liegt der Hase im Pfeffer?

animaux commented 10 years ago

Ist jetzt eine zweite Installation mit SSM-Migration.

nilshoerrmann commented 10 years ago

Meine Mutmaßung ist, dass da was in der Associationstabelle nicht stimmt.

nilshoerrmann commented 10 years ago

Ich muss mir das in Ruhe ansehen. Heute klappt das aber leider nicht mehr.

nilshoerrmann commented 10 years ago

Was einen Versucht wert wäre:

  1. Datenbank sichern.
  2. sym_associations leeren.
  3. Alle Sektionen neu speichern.
  4. Überprüfen, dass es wieder Einträge in sym_associations gibt.
animaux commented 10 years ago

Kein Problem. Ist aber wie gesagt nur bei gruppierten Datenquellen der Fall. Ich probier das gleich mal.

animaux commented 10 years ago

Meinst Du sym_fields_associations oder gar sym_sections_associations?

sym_associations gibt’s bei mir nicht.

nilshoerrmann commented 10 years ago

Sorry, letzteres.

animaux commented 10 years ago

sym_sections_associations, ja?

nilshoerrmann commented 10 years ago

ja

animaux commented 10 years ago

sym_sections_associations wird nach dem neu Speichern der Bereiche wieder gefüllt. (Die Einstellung »display associations in entries table« wird allerdings weiterhin nicht gespeichert siehe hier.)

Dein Riecher scheint aber richtig gewittert zu haben. Nachdem ich die Datenquellen neu gespeichert hatte funktionierte die Ausgabe! Hurra! Danke! :)

nilshoerrmann commented 10 years ago

Schön :)

nilshoerrmann commented 10 years ago

Wäre ein weiterer Punkt, den wir hier aufnehmen sollten: https://github.com/symphonists/association_field/issues/3

animaux commented 10 years ago

Hmnja, bei der anderen Installation war das kein Problem scheinbar.

Jetzt habe ich aber bei einer weiteren vorhandenen Datenquelle erst jetzt bilder hinzugefügt und die entsprechenden Unterfelder ausgewählt. Und leider kommt nun wieder nur Quatsch raus.

animaux commented 10 years ago

Ist die Frage ob er generell beim Erstellen einer DS mit Gruppierung erstmal was verborkt, oder ob das ein Migrationsfolgeproblem ist? (wird ja langsam politisch hier)

animaux commented 10 years ago

Wenn ich die Gruppierung in der DS ausschalte kommt der output korrekt an. Wenn ich Gruppierung dann wieder einschalte ist es wieder kaputt.

animaux commented 10 years ago

Hrmpsfsd. Es ist offensichtlich auch zu spät für mich um noch sinnvoll zu arbeiten. Der Fehler ist nicht durch das Datenbankleeren behoben worden. Die Datenquellen bei denen es funktionierte sind garnicht gruppiert … das hatte ich vorhin übersehen.

Es bleibt also dabei. Gruppierte Datenquellen bekommen nicht den korrekten associated content. :(

nilshoerrmann commented 10 years ago

Probier doch mal bitte folgendes aus: Ersetze nachfolgende Funktion – https://github.com/hananils/association_output/blob/master/extension.driver.php#L419-L451 – durch folgendes:

    private function findAssociatedEntries(&$xml, $associated_items, $name, $transcriptions)
    {
        $children = $xml->getIterator();
        if (!empty($children)) {
            foreach ($children as $child) {
                $nodeName = $child->getName();

                if ($nodeName !== 'entry') {
                    $this->findAssociatedEntries($child, $associated_items, $name, $transcriptions);
                } else {
                    $this->includeAssociatedEntries($child, $associated_items, $name, $transcriptions);;
                }
            }
        }
    }

    private function includeAssociatedEntries(&$entry, $associated_items, $name, $transcriptions)
    {
        $fields = $entry->getChildren();

        if ($entry->getName() === 'entry' && !empty($fields)) {
            foreach ($fields as $field) {
                $items = $field->getChildren();

                if ($field->getName() === $name && !empty($items)) {
                    foreach ($items as $item) {
                        $id = $item->getAttribute('id');

                        if (empty($id)) {
                            $handle = $item->getAttribute('handle');
                            $id = $transcriptions[$handle];
                        }

                        $association = $associated_items[$id];
                        if (!empty($association)) {
                            $item->replaceValue('');
                            $item->setChildren($associated_items[$id]);
                            $item->setAttribute('id', $id);
                        }
                    }
                }
            }
        }
    }
moretaste commented 10 years ago

@nilshoerrmann is this (https://github.com/brendo/uniondatasource/issues/41) related?

animaux commented 10 years ago

@nilshoerrmann Will have to try on monday! Thanks.

nilshoerrmann commented 10 years ago

@moretaste: No.

animaux commented 10 years ago

@nilshoerrmann no change :(

nilshoerrmann commented 10 years ago

Really? It worked here. Can you please post the XML output of your grouped DS (or send it to me privately)? Thanks!

animaux commented 10 years ago

Side note: the item/@handle actually reflects the selected content but not the content.

nilshoerrmann commented 10 years ago

Side note: the item/@handle actually reflects the selected content but not the content.

?!?

animaux commented 10 years ago

E. G. When I select title for accosciated output the item/@handle includes the handle of the title. But the content of the item itself still always shows the reflection field named vorschau, which is the last field in the associated section. Will send you the XML via E-Mail but it’s still the same as in the screenshot above.

nilshoerrmann commented 10 years ago

Looking at your screenshot from aboave item/@handle shows the handle of your refletion field (= the handle of the text content).

animaux commented 10 years ago

Looking at your screenshot from aboave item/@handle shows the handle of your refletion field (= the handle of the text content).

Yes that was done with different fields selected, but when I select a single field for associated output, then this particular field will be reflected in the items @handle but not in it’s actual content.

animaux commented 10 years ago

I can send you the whole installation if you want :)

nilshoerrmann commented 10 years ago

You can do so, if it's fine for you that I'll look at it tomorrow (I'm alone in the office today – Kitaferien).

animaux commented 10 years ago

OK, will do. Tomorrow will be my last da at the office before my holidays though. Will be back in September.

nilshoerrmann commented 10 years ago

Alex, probier mal das hier aus: https://github.com/hananils/association_output/releases/tag/1.0.1

animaux commented 10 years ago

Es geht! Wie immer ein großes Danke, Nils! Bitte den Code der Site vernichten :)

nilshoerrmann commented 10 years ago

Freut mich.

Bitte den Code der Site vernichten :)

Ich hätte ja jetzt erwartet, dass der Code sich in 5 Sekunden selbst zerstört. Da müsst Ihr noch dran arbeiten ;)

animaux commented 10 years ago

Ich hätte ja jetzt erwartet, dass der Code sich in 5 Sekunden selbst zerstört.

Das ging nur in Symphony 2.3!

nilshoerrmann commented 10 years ago

Haha, na dann heb ich das mal auf. Man weiß ja nie …

animaux commented 10 years ago

Ich habe mich selbst schon wieder über meinen Code gewundert … müsste das mal aufräumen. Wenn mal Zeit ist.

nilshoerrmann commented 10 years ago

Wenn mal Zeit ist.

Das ist der beste Witz seit langem! Wenn Ihr ne Agentur für Eure Seite sucht … ich kenn da eine ;)

animaux commented 10 years ago

Hehe :) läuft ja …

animaux commented 10 years ago

Sollte es in meinem Urlaub vom 20. – 30. August Symphony-basierte Notfälle geben, kann es sein dass sich jemand von uns bei Dir meldet :)