Hi,
I am using Evolution and I would have to get parent id of resource or resource id itself from within Template Variable even if resource hasn’t created yet.
I am able to get resource id already if the resource has created before. I do it with $_GET[’id’] varialble. But while I’m creating a resource it doesn’t work. Does anyone know is it posible to get working?
-
☆ A M B ☆
- 24,524 Posts
Resource IDs are assigned automatically on creation; there is simply no way to have an ID before the resource is saved to the database.
You haven’t said which version of MODx and exactly when you want the ID. As Susan says, though, until the resource is saved to the DB, it has no ID. It is possible in a plugin, however to get the ID just after the save to the DB and before the user is forwarded anywhere.
If you can tell us exactly what you’re trying to do and why (and in what version of MODx), we might be able to suggest a solution.
Thank you for answers
I use 1.0.3 version of MODx.
Maybe my question was a little bit misleading, because I need parent ID instead of resource ID. I just asked how to get resource ID because with that I could get the parent ID.
Anyway, my aim is to create many different lists of articles with different categories. One article can be in many category in one directory and I try to do this such way that I need only one template to directory, category and article. I think that it’s too tricky if I have to create own templates for every directory.
I tried to do this already but it didn’t work properly. Here is what I did:
Sitemap is like this:
Directory 1
all
article
article
etc.
category 1
catecory 2
category 3
Directory 2
all
article
article
etc.
category 1
category 2
category 3
I put all articles under all resource. The template for articles contains TV to display list of categories and categories are resources under directory resource. The TV should get category resources automaticly from under directory and display them as checkbox list. The category template uses Ditto to display articles.
In TV I get resource ID with $_GET[’id’] variable which make it posible to get parent ID of resource. When I know directory’s ID I will get all it’s childrens and display them as categories in article template.
This doesn’t work at the moment I’m creating a resource because the TV can’t get the ID from $_GET[’id’] variable. Due to this the TV isn’t able to display categories.
So is it posible to get parent ID if the resource hasn’t created yet?
I hope you understand what I mean.
when creating a new resource you can get the parent-id with $_REQUEST[’pid’]
Thanks Bruno17! Your suggestion was right near but didn’t work. I tried $_REQUEST[’parent’] and it works fine.