Hello again,
Next problem occured with my site. I’d like to show some information from my own database table for each page. To take the data from the table I need a key which is "page id".
Let’s say I have a template variable [*tvprice*] which contains a call to a non-param snippet called [!getBookPrice!]. Inside the snippet I’d like to automatically get the id of the current page. I can use $modx->documentIdentifier but it works OK only if I’m on this page.
When I use ditto to display all subpages on a parent page, I get the id of a parent page.
I thought that if I have "tv..." variable and set tagData="tvprice" in ditto call then my snippet will be executed within the context of the child page. But it is not, unfortunately.
I know I can define a parameter for the snippet and set its value each time I call a snippet but I’d prefer to build a non-non-param snippet which takes the proper ID automatically.
Is there a way to do it?
Thanks
Greg
You could skip the tvprice altogether in the Ditto call and just do [!getBookPrice?id=`[+id+]`!] and code in that $id is the current document unless $id is already set (IE from the snippet call).
Hi,
Maybe I do something wrong, but when I change my call to [!getBookPrice?id=`[+id+]`!], I get an empty value and my query finds nothing.
Did you modify the snippet to handle the $id variable.
I’m not sure if I know how to do that.
Could You please write me a simple example - just to display the id of the page for which the snippet is called.
Thanks
Greg
Hi,
I don’t think we understand each other.
My aim is to have a non-param snippet which will automatically determine the id of the page for which it is executed.
Using documentIdentifier work good when I execute each page separately but when I use ditto, I get the id of the page on which I called ditto.
Thx
Greg
I have the same kind of problem.... and it’s not working for me....
If i am using [+id+] nothing happen on each page separtly..
In fact, i’m not sure that [+id+] is undertood wihout ditto context... (but [*id*] yes no problem)
-------------------------------
www.fabienletort.com