We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53178
    • 24 Posts
    Hi,

    I have a bootstrap calendar for events that is populated by an external json file. My thought is:
    Create event resource page has the TVs,
    Then I have
    eventsContainerTpl chunk below that calls the getResource and saves to assets/template/calendar/events/events.json file which the bootstrap calendar should pick up as its source of json file

    {
        "items": [
            [[getResources? 
               &parents=`194`
               &includeContent=`1`
               &includeTVs=`1`
               &processTVs=`1`
               &showHidden=`1`
               &tvPrefix=``
               &tpl=`eventsRowTpl`
               &outputSeparator=`,`
            ]]
    		
    	]
    }


    eventsRowTpl chunk has this
    		{
    			"name": "[[+pagetitle]]",
    			"image": "[[+tv.eventCoverPage]]",
    			"day": "[[+tv.eventDate]]",
    			"color": "[[+tv.pickEventColor]]",
    			"location": "[[+tv.eventLocation]]",
    			"description": "[[+content]]"
    		}
    


    The issue is when I check the external assets/template/calendar/events/events.json file, it just has the getResource code
    {
        "items": [
            [[getResources? ... 


    and I want it have the processed getResource so it will have

    {
        "items": [
    {
    			"name": "Event 1 ",
    			"image": "assets/images/top.jpg",
    			"day": "12-1-2017",
    			"color": "1",
    			"location": "UK, london",
    			"description": "Awesome event"
    		}
    
    


    Please help.

    This question has been answered by donshakespeare. See the first response.

    • discuss.answer
      • 42562
      • 1,145 Posts
      https://docs.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/content-types

      I have a bootstrap calendar for events that is populated by an external json file.
      Is it possible to rethink your procedure? If so, consider populating the calendar with an actual MODX file/resource.
      Create a resource with contentType (JSON), and toss all your MODX code inside of it.

      Once you "view" that resource, all that getResource code would have become processed. Then take the url of that resource/page and feed it to your calendar. (hopefully you have FURL turned on)
      Cheers. [ed. note: donshakespeare last edited this post 7 years, 1 month ago.]
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 53178
        • 24 Posts
        @donshakespeare,

        You are a super hero. Thank you! It has worked.
        Cheers to you too.


        Quote from: donshakespeare at Mar 04, 2017, 04:43 PM
        https://docs.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/content-types

        I have a bootstrap calendar for events that is populated by an external json file.
        Is it possible to rethink your procedure? If so, consider populating the calendar with a an actual MODX file/resource.
        Create a resource with a contentType (JSON), and toss all your MODX code inside of it.

        Once you "view" that resource, all that getResource code would have become processed. Then take the url of that resource/page and feed it to your calendar. (hopefully you have FURL turned on)
        Cheers.
          • 42562
          • 1,145 Posts
          Glad you got that fixed.
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 53178
            • 24 Posts
            Please, one last question if you don't mind, I'm sought of fresh into modx. I have a listbox tv, "pickNo" for selection either 1,2,3,4 for my calendar. when i do [[*pickNo]] it shows the right int but when its in the eventsRowTpl chunk

            {
                "name": "[[+pagetitle]]",
                "image": "[[+tv.eventCoverPage]]",
                "day": "[[+tv.eventDate]]",
                "color": "[[+tv.pickEventColor]]",
                "location": "[[+tv.eventLocation]]",
                "description": "[[+content]]"
                "Number":"[[+tv.pickNo]]"
            }
            


            it does not show the number. What am i doing wrong?

            Quote from: donshakespeare at Mar 04, 2017, 05:01 PM
            Glad you got that fixed.
              • 4172
              • 5,888 Posts
              you forgot a comma

              "description": "[[+content]]",
              
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 42562
                • 1,145 Posts
                Good catch.
                  TinymceWrapper: Complete back/frontend content solution.
                  Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                  5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                  • 53178
                  • 24 Posts
                  Yes very nice catch.
                  As I had mentioned, new in Modx but loving it.
                  In my json, description is
                  "description": "[[+content]]", 
                  which is user input using rich text ("tiny MCE"). An issue I am facing is escaping the double quotes. Is there a built in functionality in modx that I can use to escape the double quotes. I saw this link https://forums.modx.com/index.php/topic,67146.msg380971.html , JamesLaugesen talks about he created his own custom modifier and had something like this:

                  "description": "[[+content:tojson]]",


                  :tojson custom modifier
                  //$output = $modx->toJSON($input);
                  $output = json_encode($input);
                  return $output;


                  Would this work?

                  Quote from: Bruno17 at Mar 05, 2017, 12:17 PM
                  you forgot a comma

                  "description": "[[+content]]",
                  
                    • 53178
                    • 24 Posts
                    Happy news, I was able to escape the invalid characters, like comma, tabs, newlines, etc. JamesLaugesen contribution in this link https://forums.modx.com/index.php/topic,67146.msg380971.html really helped me. For those who might see this its:
                    "description": [[+content:tojson]]


                    Watch out you don't put the double quotes.

                    :tojson custom modifier
                    $output = json_encode($input);
                    return $output;
                    


                    Thank you all those who helped!! @donshakespeare and @Bruno17



                    Quote from: jsheke at Mar 06, 2017, 08:55 AM
                    Yes very nice catch.
                    As I had mentioned, new in Modx but loving it.
                    In my json, description is
                    "description": "[[+content]]", 
                    which is user input using rich text ("tiny MCE"). An issue I am facing is escaping the double quotes. Is there a built in functionality in modx that I can use to escape the double quotes. I saw this link https://forums.modx.com/index.php/topic,67146.msg380971.html , JamesLaugesen talks about he created his own custom modifier and had something like this:

                    "description": "[[+content:tojson]]",


                    :tojson custom modifier
                    //$output = $modx->toJSON($input);
                    $output = json_encode($input);
                    return $output;


                    Would this work?

                    Quote from: Bruno17 at Mar 05, 2017, 12:17 PM
                    you forgot a comma

                    "description": "[[+content]]",