We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27160
    • 50 Posts
    What I want to do is describe the blog section on the page where the blog posts are. Such as

    "Home & Family"
    Home, kids, pets and life in realtime.

    I'm open to alternate suggestions if the following won't work. smiley

    Can you put a get resource call in a template variable such as this?

    [[getResources? &id=`[[7]]` &field=`introtext`]]

    If not, can you put a get resourcefield call in such as this?

    [[getResourceField? &id=`[[7]]` &field=`introtext`]]


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

      Linda Jenkinson
      • 3749
      • 24,544 Posts
      How about just using getResources the old fashioned way, with an '+introtext' placeholder in the Tpl chunk?

      Or, if you're only looking for a single resource, a simple snippet:

      [[!GetIntrotext? &docId=`7`]]
      


      /* GetIntrotext snippet */
      $docId = $modx->getOption('docID', $scriptProperties, '');
      $query = $modx->newQuery('modResource', array(
          'id' => $docId,
      ));
      $query->select('introtext');
      return $modx->getValue($query->prepare());









        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 27160
        • 50 Posts
        Quote from: BobRay at Oct 18, 2014, 09:56 PM
        How about just using getResources the old fashioned way, with an '+introtext' placeholder in the Tpl chunk?


        Because it needs to do it for several parent pages. It isn't only id 7 there are 5 others. So I thought if I could put that in a template variable, I could call the parent infotext I want for each new blog post.

        My site is http://shyflower.com. If you look, you'll see there is a white space at the top between the navigation and the sidebar. That's the space I want to use.
          Linda Jenkinson
          • 27160
          • 50 Posts
          Quote from: BobRay at Oct 18, 2014, 09:56 PM
          How about just using getResources the old fashioned way, with an '+introtext' placeholder in the Tpl chunk?


          Because it needs to do it for several parent pages. It isn't only id 7 there are several others. I thought if I could put that in a template variable, I could call the parent infotext I want for each new blog post.

          My site is http://shyflower.com. If you look, you'll see there is a white space at the top between the navigation and the sidebar. That's the space I want to use.
            Linda Jenkinson
            • 3749
            • 24,544 Posts
            How about this? smiley


            [[!GetIntrotext? &docId=`[[*name_of_tv_holding_id]]`]]
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 27160
              • 50 Posts

              Quote from: BobRay at Oct 19, 2014, 10:20 PM
              How about this? smiley


              [[!GetIntrotext? &docId=`[[*name_of_tv_holding_id]]`]]

              I see how that could work, but then how do I add the parent id's in the template variable? I've only used text in tv's before. Do I need the brackets and the tics such as
              `[[7]]` | `[[8]]'
              or just the numbers?

                Linda Jenkinson
                • 3749
                • 24,544 Posts
                If there's only one ID in each TV, you just need the number. If there's more than one, we need a whole new strategy. wink

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 27160
                  • 50 Posts


                  Quote from: BobRay at Oct 20, 2014, 05:19 PM
                  If there's only one ID in each TV, you just need the number. If there's more than one, we need a whole new strategy. wink


                  Okay, I think I need a whole new strategy.

                  My blog has sections that are Home & Family (7), Writing (8) , Freelance(10), Enviro(24), Politics(25), and Reviewed(26). Each of those are the parent pages. Right now the only content in each parent page is the get resources to call its children into the content of the template. What I want to do is call the parent Page Title and its info text to the blank space so that when the blog post is from the home section, the blank space will describe the blog section, and the blank space will describe the writing section when the post is from that section.

                  I could do it with text in a tv, but I thought that since the parent already has a page title and a space for infotext, it would be easier to do a template variable. Maybe not?
                  My biggest concern about doing this right is that I don't mess up the php and lock myself out of the site, otherwise I would just give it a try.
                    Linda Jenkinson
                    • 3749
                    • 24,544 Posts
                    I think I understand what you want. This should do it (untested):

                    ParentInfo Tpl chunk (modify it to meet your needs, but be careful not to change the placeholders):

                    <div class="parent_info">
                        <p>[[+pagetitle]] — [[+introtext]]</p>
                    </div>
                    


                    Parent Info snippet tag (put this where you want the info to appear):

                    [[!ParentInfo]]



                    Create a snippet called ParentInfo with this code:

                    <?php
                    /* ParentInfo snippet */
                    $output = '';
                    $parent = $modx->getObject('modResource', array('id' => $modx->resource->get('parent'));
                    if ($parent) {
                       $output =  $modx->getChunk('ParentInfo', $parent->toArray());
                    }
                    return $output;
                    


                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 27160
                      • 50 Posts

                      Quote from: BobRay at Oct 20, 2014, 05:19 PM
                      whole new strategy. wink


                      Thanks Bob, This looks good. I'll try it out tomorrow and let you know how it works.
                        Linda Jenkinson