Call a chunk in a chunk (tpl)?

Hi,

I’m currently creating a book page and there is a subpage for each book with information about the books and links to specific shops.

For each link I did the following:

  1. I created a TV called „shop-link-1“ (Example):
    shop-link-1

  2. Than I created a chunk called „shop-link-1“:
    ← a href = " [[*shop-link-1]] " target=“_blank”> Shop</a →

  3. After this I created a chunk called „buy“ for all the links:
    [[*shop-link-1:notempty=[[$shop-link-1]]]]
    [[*shop-link-2:notempty=[[$shop-link-2]]]]
    [[*shop-link-3:notempty=[[$shop-link-3]]]]

Then I called the chunk [[$buy]] an the subpage and it worked.

Now I want to show the bookcover und the links together with other books on a mainpage. Therefore I created a tpl:

<img class="img-fluid" src="[[+tv.book-cover]]" alt="[[+tv.book-alt-text]]"

 

Buy:

Here I want to show the shop links from the subpage. But I don’t know, how I call the content of a chunk [[$buy]] ? So I have to do it for the other books too.

</div><!-- row -->

Can someone help?

Thanks,
Micha

I am an absolute beginner. I found the chunk in my example in a forum und used it. I have no idea of writing a chunk or php on my own.

Thanks,
Micha

Are you using the snippet getResources (or maybe pdoResources) for this?

I’m not sure I understand your question correctly, but the problem is probably, that a tag like [[*shop-link-1]] (you use in the chunk) is only for the TV-value of the requested resource.

If you list content from other resources on a page with getResources, then you have to use placeholder tags (like [[+tv.name_of_tv]]) instead.

So you probably have to create a new chunk with code like this

[[+tv.shop-link-1:notempty=`<a href="[[+tv.shop-link-1]]" target="_blank">Shop</a>`]]
...

and use that to show the ‘buy’-links in the book list. (Or just add the code to the existing “tpl”.)

1 Like

I’m using getResource.

Thanks a lot for your help. I have tested your solution und I think it worked. :slight_smile: