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

    I am using the getResources snippet to output products on a product category page. My menu tree looks as follows:
    + Product Categories
    ++ Category 1
    ++ Category 1
    ++ Category 1

    In every chunk being output I need a link pointing back to its corresponding resource ("Category 1", "Category 2", ...):
    "Product Categories":
    Category1
    Link to Category1
    ....
    Category2
    Link to Category2
    ...
    Category3
    Link to Category3

    Unfortunately all I have been able to accomplish so far is a link pointing to the page where the snippet has been called ("Product Categories").

    Below is my snippet call, the corresponding template chunk and a custom snippet I wrote to help me set the link. It would be great if someone could show me what I did wrong!

    Snippet call:
    [[getResources? 
    &tpl=`CHILLY-products-gallery` 
    &parents=`2` 
    &includeTVs=`1`
    &sortby=`menuindex`
    ]]


    Template [[$CHILLY-products-gallery]]:
    <div><img src="[[+tv.CHILLY-product_category-image]]" alt="pic1" />
      <p>
        <b>[[+pagetitle]]</b>Some project details and blah blah blah
        <a href="[[~[[get_id]]]]">Specifications...</a>
      </p>
    </div>


    Snippet [[get_id]]:
    return $modx->resource->get('id');


    Cheers,

    Stefan
      • 4414
      • 63 Posts
      Could it be that I can’t link back using getResources? So far I haven’t been able to find manual describing all its features, that’s why I hope someone here in this forum could help me with my little problem.
        • 13694
        • 3 Posts
        Hey, did you ever figure this out? I’m having the same problem at the moment.
          • 28215
          • 4,149 Posts
          You mean this?

          <a href="[[~[[+id]]]]">[[+pagetitle]]</a>
          
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 13694
            • 3 Posts
            *Update* Crap, yes I do mean that. Sorry, when I first read it I thought your "code" was a "quote" of what he posted. Thanks for the solution.

            No, I meant his overall general question of how do you get the getResource snippet to return a template chunk that contains a link back to that document. I am also running into his problem where any links I try and use just go to the parent of those resources (the page that the getResource is called on).



            Quote from: splittingred at Aug 08, 2010, 09:44 PM

            You mean this?

            <a href="[[~[[+id]]]]">[[+pagetitle]]</a>