We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37242 ☆ A M B ☆
    • 339 Posts
    Hi MODX People,

    I am trying to set up a kind of calendar on my new website.

    I use gesResources to get all events from a folder. That is working so far.

    Inside the eventTpl, I have another getResources call to get more info on the location the event is happening at (location name, lon/lat for a map etc). This info is stored in another resource which describes the location.

    Unfortunately, it's not giving any output at all. Maybe you can help me out here:

    calendar chunk:
    [[!getPage?
    &elementClass=`modSnippet`
    &element=`getResources`
    
    &parents=`77`
    &resources=`-78, -163`
    
    &includeContent =`false`
    &includeTVs=`1`
    &processTVs=`1`
    &sortbyTV = `Eventdate`
    &sortbyTVType= `datetime`
    &sortdirTV = `DESC`
    
    &tpl=`ShortEventTpl`
    &tpl_n4= `ShortEventTpl4`
    &pageNavOuterTpl=`[[+prev]][[+pages]][[+next]]`
    
    ]]
    <br />
    <div class="pageNav">[[!+page.nav]]</div>


    shortEventTpl (the 1st tv.Location is only set for testing):
    <div class="three columns event">
    <h4>
    <a href="[[~[[+id]]]]" title="[[+pagetitle]]" style="-webkit-transform: rotate([[+editedon:reverse:limit=`1`:subtract=`4`]]deg) translate3d( 0, 0, 0);-moz-transform: rotate([[+editedon:reverse:limit=`1`:subtract=`4`]]deg);-ms-transform: rotate([[+editedon:reverse:limit=`1`:subtract=`4`]]deg);">[[+pagetitle]]</a>
    </h4>
    <p><em>[[+tv.Eventdate:strtotime:date=`%e.%m.%Y`]], [[+tv.Location]], [[!getResources? &parents=`[[+tv.Location]]` &tpl=`eventLocationTpl` &includeTVs=`1` &processTVs=`1`]]</em><br />
    [[+content:notags:ellipsis=`200`]]<a href="[[~[[+id]]]]" title="[[+pagetitle]]"> [mehr...]</a></p>
    </div>


    eventLocationTpl:
    <a href="[[~[[!+id]]]]" title="[[!+pagetitle]]">[[!+tv.pagetitle]]</a>


    I dont get any output from the second getResources call. I had it display false links (all the same), but that is not what I want smiley

    Any clues?

    Cheers,

    Guido
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Mark Hamstra Reply #2, 14 years ago
      In shortEventTpl, what does [ [+tv.Location]] output?

      And why, oh please why, is getResources uncached and are you uncaching those placeholders in the eventLocationTpl as well? That doesn't make much sense.. [ed. note: markh last edited this post 14 years ago.]
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 37242 ☆ A M B ☆
        • 339 Posts
        This was just a snapshot of what I am trying at the moment.

        You mean I should cache it all? I understood from here: http://rtfm.modx.com/display/ADDON/getPage#getPage-Usage that its no good to call it cachable.

        I'll give it a try...
          • 37242 ☆ A M B ☆
          • 339 Posts
          Ok. Current calendar chunk (part):
          <p><em>[[+tv.Eventdate:strtotime:date=`%e.%m.%Y`]], id:[[+tv.Location]], [[getResources? &parents=`[[+tv.Location]]` &tpl=`eventLocationTpl` &includeTVs=`1` &processTVs=`1` &showHidden=`1` &tvPrefix=`tv2.` ]]</em><br />
          [[+content:notags:ellipsis=`200`]]<a href="[[~[[+id]]]]" title="[[+pagetitle]]"> [mehr...]</a></p>


          tv2. to separate the different output of +id

          current eventLocationTpl:
          <a href="[[~[[+id]]]]" title="[[+tv2.pagetitle]]">Loc: [[+tv2.pagetitle]], ID: [[+id]]</a>


          Output: http://www2.luisenviertel.com/termine-und-veranstaltungen-im-luisenviertel.html
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            Mark Hamstra Reply #5, 14 years ago
            Sorry, the forum parser ate up the most important part of my question:
            ... what does [ [+tv.Location]] output?

            In your last eventLocationTpl, remember that pagetitle isn't a TV, it's a resource field so tvPrefix doesn't work on that.

            You don't want to cache getPage, but you can (and in 99,9% of the cases WANT) to cache anything inside the tpl chunk.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 37242 ☆ A M B ☆
              • 339 Posts
              Ok, I resolved it:
              [[getResources? &parents=`-1` &resources=`[[+tv.Location]]` &tpl=`eventLocationTpl` &includeTVs=`1` &processTVs=`1` &showHidden=`1`]]

              I set parents to -1 and resources to the resource. Works nicely!

              Thank you once again!
                • 37242 ☆ A M B ☆
                • 339 Posts
                Quote from: markh at Oct 03, 2012, 06:10 PM
                In your last eventLocationTpl, remember that pagetitle isn't a TV, it's a resource field so tvPrefix doesn't work on that.
                Nope, pagetitle is the title of the other page, not the current. So its inside a tv and must be displayed in a placeholder.
                  • 37242 ☆ A M B ☆
                  • 339 Posts
                  OK, I'll give it a try as a resource field... Just to make sure!
                    • 18373 ☆ A M B ☆
                    • 3,141 Posts
                    Mark Hamstra Reply #9, 14 years ago
                    Nope, pagetitle is the title of the other page, not the current. So its inside a tv and must be displayed in a placeholder.

                    Nuh uh.

                    Yes it's from a different page (but so are any TVs you could be including), but a pagetitle is a core field belonging to a resource, while a TV is configurable. TVs are handled very differently under the hood and only TVs are affected by &tvPrefix.

                    As they're all from a different resource, you use the [[+ syntax instead of [[* - that doesn't affect the definition of a resource field or a TV. Why [[+ instead of [[*: https://www.markhamstra.com/modx-blog/2012/2/placeholders-resource-fields-tags/

                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 37242 ☆ A M B ☆
                      • 339 Posts
                      Ok, got what you ment. Yes, you're right. It all makes more and more sense smiley