o5_puschnig
I'm new here

Migration FS_LIST to FS_CATALOG (in DB-Schema template)

Jump to solution

Hello,

we're just finishing the migration of the FS_LIST components in our templates (we're late, I know). Most things worked as expected, but now I have run into problem.

In a DB-Schema template, we had one FS_LIST component (type inline, for section templates) which was replaced with a FS_CATALOG component as per the migration guide. The replacement has worked as far as I can tell: When viewing an entry in the corresponding datasource, the catalog component is shown and its entries are there.

I changed the HTML output of the template as follows (gallery is the mapped column for the FS_CATALOG field in the form):

...

$CMS_FOR(picture, #row.gallery)$

  $CMS_VALUE(picture.item)$

$CMS_END_FOR$

...

When using "Display preview errors" for an entry in the datasource now, I see errors like:

09.06.2020 13:10:20.968 WARN  ($CMS_VALUE(picture.item)$ at 207, 7): Replacing null value with empty default! Undefined field 'item'!

My assumption was that this happens because the values in the database are still stored in the old FS_LIST format? So I manually re-saved an entry to update it. After doing so, the preview errors disappeared.

But now the list entries do not appear anymore on the page. In fact, the list is shown as empty when I add some debugging information in the HTML:

$CMS_VALUE(#row.gallery.size())$   $-- shows 0 ??? and #row.gallery.isEmpty would evaluate to true --$

But the FS_CATALOG entries are clearly there in the datasource entry...

What has happened here? Do I need to access the FS_CATALOG differently here? Any info would be appreciated.

0 Kudos
1 Solution

Accepted Solutions

Hello Ingmar,

AFAIK:

  • #row is for direct accesssing the DB-Entries / Information
    • for Catalogs here there is XML-Data to parse
  • ptGallery is for acessing the form
    • Form-Items to parse

I would always use the Form-Data, unless there is no other way to access the Data

View solution in original post

0 Kudos
9 Replies
Nitros
I'm new here

I think you are mixing up Dataset and Entity here. From the Documentation: "#row returns an object of the data type Entity". However, the syntax you use here suggest you want a Catalog object. This can only be gotten from the FormData of the Dataset as far as I know. You could try #global.dataset instead and then follow the API of Dataset.

As a general tip: Try adding .class to then end of an expression and debug print it. This way you can figure out if the return type is what you expect.

0 Kudos

Thanks for the answer!

Yes, I want a Catalog object because in the form I have a FS_CATALOG component. So how can I access its entries, or fields of the entries in the page here (btw. the same question if I used a FS_INDEX component)? Is there no way to do this via #row??

I cannot find any information about #global.dataset, do you have a link maybe?

0 Kudos

Hello,

as this has not really been answered yet, I would like to ask if anyone else could help here.

When I print the value of #row.gallery.class I get "de.espirit.firstspirit.generate.IdentifiableFormDataList", but I do not know how to access its members. I could not find any documentation about it and as said before when checking with size or isEmpty the list always seems to be empty although there are existing entries in it.

Has anyone else successfully iterated over a FS_CATALOG component inside a DB Schema template before?

0 Kudos

Hello Ingmar,

could you provide more information of your construct? What are the elements of the form? How are they mapped to the DB? How is the code in the output?

Best regards

Bianca

0 Kudos

Hello Bianca,

in the form of the DB Schema template we have the following FS_CATALOG component which was migrated from an FS_LIST component:

<FS_CATALOG name="ptGallery" useLanguages="no">

        <LANGINFOS>

          <LANGINFO lang="*" label="Gallery pictures" description="Choose up to four pictures, please use only the 'Picture' tab."/>

          <LANGINFO lang="DE" label="Galeriebilder" description="Wählen Sie bis zu vier Bilder aus, bitte nur den Reiter 'Bild' verwenden."/>

        </LANGINFOS>

        <TEMPLATES type="section">

          <TEMPLATE uid="st_picture_text_linklist__tt"/>

        </TEMPLATES>

      </FS_CATALOG>

The template "st_picture_text_linklist__tt" is a paragraph template which provides the information for a picture.

The field "ptGallery" is mapped to the DB column "gallery"

Here is the HTML output of the the DB schema template:

$CMS_IF(!#row.gallery.isEmpty)$

                <div class="thumb">

                $CMS_SET(setPurpose,"productthumb")$

                $CMS_SET(setTitle,#row.name)$

                $CMS_SET(count,0)$

                $CMS_FOR(picture, #row.gallery)$

                    $CMS_IF(count <= 3)$

                        $CMS_VALUE(picture.item)$

                        $CMS_SET(count, count + 1)$

                    $CMS_END_IF$

                $CMS_END_FOR$

                </div>

                $CMS_END_IF$

Please let me know if you need more information and thank you very much for your support!

0 Kudos

Hi Ingmar,

why do you use #row and not ptGallery? Is there anything I dont recognize?

Greets Bianca

0 Kudos

Hi Bianca,

that is a good question. The template was built before using #row for accessing every element. For most elements this seems to work and I think it also worked for the FS_LIST element before. I assumed using #row was necessary because we have a DB schema template.

However, I tried your suggestion and used ptGallery and this seems to work here! I would be very thankful if you could explain briefly when to use #row and when not.

Thank you very much!

0 Kudos

Hello Ingmar,

AFAIK:

  • #row is for direct accesssing the DB-Entries / Information
    • for Catalogs here there is XML-Data to parse
  • ptGallery is for acessing the form
    • Form-Items to parse

I would always use the Form-Data, unless there is no other way to access the Data

0 Kudos

OK, thanks again. Your information was very helpful!

0 Kudos