Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-7077

Add tool to get the data structure of an object in templates

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 5.5.6
    • None
    • None
    • None
    • Yes
    • Kromeriz 101, Kromeriz 103, Kromeriz 104, Kromeriz 105
    • 8

      Some way for a templater to output the structure and content of an object within a template for development purposes.

      Why:
      It can be hard to work with content objects in a template because you do not know the structure of the content.
      It can be especially hard to understand the actual structure of the objects returned from models. Ideally a simple method in cmsfn would give a templater a string representation of the object.

      Implementation:

      Example usage:

      ${cmsfn.dump(myObject)} # outputs object properties as text with default depth of 3
      or
      ${cmsfn.dump(myObject, 5)} # outputs object properties as text with depth of 5
      or
      ${cmsfn.dump(myObject, 5, true)} # outputs object properties as html with depth of 5
      

      Describers for following types are provided out of the box:

      • Null
      • Scalars
      • Dates
      • Calendar
      • Arrays
      • Collections
      • Maps
      • ContentMaps
      • Nodes
      • Properties
      • Objects (this one describes only the object class to avoid generating huge hierarchies)

      Node:

      Node (/magnolia-travels/Vietnam--Tradition-and-Today)
        author = "Magnolia Travels" (String)
        body = "<p>Vietnam is one of the world&rsquo;s most exotic and culturally rich destinations. A gem..." (String)
        body_de = "<p>Vietnam ist eine der exotischsten und kulturreichsten Destinationen weltweit. Als Juwel unt..." (String)
        description = "Discover the culture and everyday treasures of a rising phoenix" (String)
        description_de = "Entdecken Sie die Kultur und die alltäglichen Schätze eines Phoenix aus der Asche" (String)
        destination = Sequence (1)
          0 = "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2" (String)
        duration = "14" (String)
        image = "jcr:1044b3b8-30b1-48fe-8078-832b6cef8fb5" (String)
        isFeatured = true (Boolean)
        location = "Ho Chi Minh City, Vietnam" (String)
        name = "Vietnam: Tradition and Today" (String)
        name_de = "Vielfältiges Vietnam" (String)
        tourTypes = Sequence (2)
          0 = "415025c6-e4b5-4506-9384-34f428a52104" (String)
          1 = "e007e401-1bf8-4658-8293-b9c743784264" (String)
        mgnl:activationStatus = true (Boolean)
        mgnl:comment = "" (String)
        mgnl:created = Jan 29, 2015 07:57:18 AM (Date)
        mgnl:createdBy = "superuser" (String)
        mgnl:lastActivated = Jul 1, 2015 08:48:49 AM (Date)
        mgnl:lastActivatedBy = "superuser" (String)
        mgnl:lastModified = Jun 18, 2015 12:20:06 PM (Date)
        mgnl:lastModifiedBy = "superuser" (String)
        jcr:created = Jun 12, 2017 01:41:27 PM (Date)
        jcr:createdBy = "admin" (String)
        jcr:primaryType = "mgnl:content" (String)
        jcr:uuid = "3d676477-eabc-4cbe-88b6-b77aa85a358a" (String)
      

      Property:

      Magnolia Travels (Property)
      

      Multivalue Property:

      Property (2)
        0 = "415025c6-e4b5-4506-9384-34f428a52104" (String)
        1 = "e007e401-1bf8-4658-8293-b9c743784264" (String)
      

      ContentMap:

      ContentMap (/magnolia-travels/Vietnam--Tradition-and-Today)
        author = "Magnolia Travels" (String)
        body = "<p>Vietnam is one of the world&rsquo;s most exotic and culturally rich destinations. A gem..." (String)
        body_de = "<p>Vietnam ist eine der exotischsten und kulturreichsten Destinationen weltweit. Als Juwel unt..." (String)
        depth = null (Null)
        description = "Discover the culture and everyday treasures of a rising phoenix" (String)
        description_de = "Entdecken Sie die Kultur und die alltäglichen Schätze eines Phoenix aus der Asche" (String)
        destination = Sequence (1)
          0 = "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2" (String)
        duration = "14" (String)
        id = null (Null)
        image = "jcr:1044b3b8-30b1-48fe-8078-832b6cef8fb5" (String)
        isFeatured = true (Boolean)
        location = "Ho Chi Minh City, Vietnam" (String)
        name = "Vietnam: Tradition and Today" (String)
        name_de = "Vielfältiges Vietnam" (String)
        nodeType = null (Null)
        path = null (Null)
        tourTypes = Sequence (2)
          0 = "415025c6-e4b5-4506-9384-34f428a52104" (String)
          1 = "e007e401-1bf8-4658-8293-b9c743784264" (String)
        mgnl:activationStatus = true (Boolean)
        mgnl:comment = "" (String)
        mgnl:created = Jan 29, 2015 07:57:18 AM (GregorianCalendar)
        mgnl:createdBy = "superuser" (String)
        mgnl:lastActivated = Jul 1, 2015 08:48:49 AM (GregorianCalendar)
        mgnl:lastActivatedBy = "superuser" (String)
        mgnl:lastModified = Jun 18, 2015 12:20:06 PM (GregorianCalendar)
        mgnl:lastModifiedBy = "superuser" (String)
        jcr:created = Jun 12, 2017 01:41:27 PM (GregorianCalendar)
        jcr:createdBy = "admin" (String)
        jcr:primaryType = "mgnl:content" (String)
        jcr:uuid = "3d676477-eabc-4cbe-88b6-b77aa85a358a" (String)
      

      Sequence of ContentMaps:

      Sequence (36)
        0 = ContentMap (/magnolia-travels/Vietnam--Tradition-and-Today)
          author = "Magnolia Travels" (String)
          body = "<p>Vietnam is one of the world&rsquo;s most exotic and culturally rich destinations. A gem..." (String)
          body_de = "<p>Vietnam ist eine der exotischsten und kulturreichsten Destinationen weltweit. Als Juwel unt..." (String)
          depth = null (Null)
          description = "Discover the culture and everyday treasures of a rising phoenix" (String)
          description_de = "Entdecken Sie die Kultur und die alltäglichen Schätze eines Phoenix aus der Asche" (String)
          destination = Sequence (1)
            0 = "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2" (String)
          duration = "14" (String)
          id = null (Null)
          image = "jcr:1044b3b8-30b1-48fe-8078-832b6cef8fb5" (String)
          isFeatured = true (Boolean)
          location = "Ho Chi Minh City, Vietnam" (String)
          name = "Vietnam: Tradition and Today" (String)
          name_de = "Vielfältiges Vietnam" (String)
          nodeType = null (Null)
          path = null (Null)
          tourTypes = Sequence (2)
            0 = "415025c6-e4b5-4506-9384-34f428a52104" (String)
            1 = "e007e401-1bf8-4658-8293-b9c743784264" (String)
          mgnl:activationStatus = true (Boolean)
          mgnl:comment = "" (String)
          mgnl:created = Jan 29, 2015 07:57:18 AM (GregorianCalendar)
          mgnl:createdBy = "superuser" (String)
          mgnl:lastActivated = Jul 1, 2015 08:48:49 AM (GregorianCalendar)
          mgnl:lastActivatedBy = "superuser" (String)
          mgnl:lastModified = Jun 18, 2015 12:20:06 PM (GregorianCalendar)
          mgnl:lastModifiedBy = "superuser" (String)
          jcr:created = Jun 12, 2017 01:41:27 PM (GregorianCalendar)
          jcr:createdBy = "admin" (String)
          jcr:primaryType = "mgnl:content" (String)
          jcr:uuid = "3d676477-eabc-4cbe-88b6-b77aa85a358a" (String)
        1 = ContentMap (/magnolia-travels/Hut-to-Hut-in-the-Swiss-Alps)
          author = "Magnolia Travels" (String)
          body = "<p>Some Swiss people are going to be pretty annoyed with us for revealing their secrets. Hush...." (String)
          body_de = "<p>Einige Schweizer werden sich &auml;rgern, dass wir ihre Geheimnisse aufdecken. Psst... ..." (String)
          depth = null (Null)
          description = "There's more to Switzerland than skiing" (String)
          description_de = "Die Schweiz ist mehr als nur Skifahren" (String)
          destination = Sequence (1)
            0 = "6cc50e28-fb0e-4e49-b3b6-728690a2e861" (String)
          duration = "7" (String)
          id = null (Null)
          image = "jcr:80d091ae-22ce-4cfc-b302-cb39f25c3d30" (String)
          location = "Zurich, Switzerland" (String)
          name = "Hut to Hut in the Swiss Alps" (String)
          name_de = "Von Hütte zu Hütte in den Schweizer Alpen" (String)
          nodeType = null (Null)
          path = null (Null)
          tourTypes = Sequence (1)
            0 = "eaf9a648-fae1-48ae-a293-69bed874f159" (String)
          mgnl:activationStatus = true (Boolean)
          mgnl:comment = "" (String)
          mgnl:created = Jan 29, 2015 07:55:07 AM (GregorianCalendar)
          mgnl:createdBy = "superuser" (String)
          mgnl:lastActivated = Jul 1, 2015 08:48:52 AM (GregorianCalendar)
          mgnl:lastActivatedBy = "superuser" (String)
          mgnl:lastModified = Jun 18, 2015 11:36:14 AM (GregorianCalendar)
          mgnl:lastModifiedBy = "superuser" (String)
          jcr:created = Jun 12, 2017 01:41:27 PM (GregorianCalendar)
          jcr:createdBy = "admin" (String)
          jcr:primaryType = "mgnl:content" (String)
          jcr:uuid = "d30b9ca6-e22d-45c5-9456-7538ab7bccf8" (String)
        2 = ContentMap (/magnolia-travels/West-Coast---Highway-101)
          author = "Magnolia Travels" (String)
          body = "<p>Imagine walking in the footsteps of the explorers, missionaries, and soldiers who made Amer..." (String)
          body_de = "<p>Stellen Sie sich vor, dass Sie auf den Spuren der Forscher, Missionare und Soldaten unterwe..." (String)
          depth = null (Null)
          description = "Family travels in USA" (String)
          description_de = "Familienreisen in den USA" (String)
          destination = Sequence (1)
            0 = "ed3dcd18-78af-46df-a9e1-bc732479f2e7" (String)
          duration = "7" (String)
          id = null (Null)
          image = "jcr:d44f783c-91ca-4b48-9533-ea4e147e13e9" (String)
          location = "Seattle, USA" (String)
          name = "West Coast - Highway 101" (String)
          name_de = "Westküste - Highway 101" (String)
          nodeType = null (Null)
          path = null (Null)
          tourTypes = Sequence (1)
            0 = "17da160b-da66-4e09-9e31-5fd040880f4a" (String)
          mgnl:activationStatus = true (Boolean)
          mgnl:comment = "" (String)
          mgnl:created = Jan 29, 2015 07:51:38 AM (GregorianCalendar)
          mgnl:createdBy = "superuser" (String)
          mgnl:lastActivated = Jul 1, 2015 08:48:56 AM (GregorianCalendar)
          mgnl:lastActivatedBy = "superuser" (String)
          mgnl:lastModified = Jun 18, 2015 11:40:45 AM (GregorianCalendar)
          mgnl:lastModifiedBy = "superuser" (String)
          jcr:created = Jun 12, 2017 01:41:27 PM (GregorianCalendar)
          jcr:createdBy = "admin" (String)
          jcr:primaryType = "mgnl:content" (String)
          jcr:uuid = "730c8850-d638-4e91-b3fb-4041a0c59ffe" (String)
        3 = ContentMap (/magnolia-travels/Inside-New-Delhi)
          author = "Magnolia Travels" (String)
          body = "<p>Delhi has many interesting monuments and museums, but <em>we won&#39;t be visitin..." (String)
          body_de = "<p>Delhi hat viele interessante Baudenkm&auml;ler und Museen, aber wir besuchen auf dieser..." (String)
          depth = null (Null)
          description = "Get to know Delhi up close and personal" (String)
          description_de = "Lernen Sie Delhi ganz aus der Nähe und intim kennen" (String)
          destination = Sequence (1)
            0 = "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2" (String)
          duration = "2" (String)
          id = null (Null)
          image = "jcr:ad33e9b0-855e-4bac-b35e-3c7e7588465c" (String)
          location = "New Delhi, India" (String)
          name = "Inside New Delhi" (String)
          name_de = "In Neu Delhi eintauchen" (String)
          nodeType = null (Null)
          path = null (Null)
          tourTypes = Sequence (2)
            0 = "415025c6-e4b5-4506-9384-34f428a52104" (String)
            1 = "e007e401-1bf8-4658-8293-b9c743784264" (String)
          mgnl:activationStatus = true (Boolean)
          mgnl:comment = "" (String)
          mgnl:created = Jan 29, 2015 07:50:20 AM (GregorianCalendar)
          mgnl:createdBy = "superuser" (String)
          mgnl:lastActivated = Jul 1, 2015 08:49:03 AM (GregorianCalendar)
          mgnl:lastActivatedBy = "superuser" (String)
          mgnl:lastModified = Jun 18, 2015 11:41:28 AM (GregorianCalendar)
          mgnl:lastModifiedBy = "superuser" (String)
          jcr:created = Jun 12, 2017 01:41:27 PM (GregorianCalendar)
          jcr:createdBy = "admin" (String)
          jcr:primaryType = "mgnl:content" (String)
          jcr:uuid = "3ba5ba55-ac02-4b37-a429-5fc0bb4b383b" (String)
      ...
      

      Hash:

      Hash (2)
        foo = "bar" (String)
        baz = Hash (3)
          i = "am" (String)
          nested = "hash" (String)
          yay! = Hash (1)
            hi = "bye" (String)
      

        Acceptance criteria

              jsimak Jaroslav Simak
              czimmermann Christopher Zimmermann
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: