joer80 Posted March 25, 2019 Share Posted March 25, 2019 I am trying to add a child page to a user and I am getting an error. Enabled the user template to have children but when I add a child page there is an error. Does anyone have any ideas? The error is: "The template 'user' does not allow parents of type 'user'" but it never lets me select the template I allowed. Thanks! Link to comment Share on other sites More sharing options...
Gideon So Posted March 25, 2019 Share Posted March 25, 2019 Hi @joer80, 1. Go the Setup --> Templates, click Filters. Then set "show system templates" to Yes. 2. Click "user" template 3. click Family tab 4. set "May this template has childern" to Yes. 5. set templates allowed for this template if necessary. But please think twice before you do this. It is not encouraged to add children to user page. It is better to create a separate page with page reference field that set to choose from user pages. Gideon 1 Link to comment Share on other sites More sharing options...
joer80 Posted March 25, 2019 Author Share Posted March 25, 2019 7 hours ago, Gideon So said: Hi @joer80, 1. Go the Setup --> Templates, click Filters. Then set "show system templates" to Yes. 2. Click "user" template 3. click Family tab 4. set "May this template has childern" to Yes. 5. set templates allowed for this template if necessary. But please think twice before you do this. It is not encouraged to add children to user page. It is better to create a separate page with page reference field that set to choose from user pages. Gideon I enabled the user template to have children of the correct template but it does not allow it to have children. It just gives the error I posted. I am wondering if it is a bug. In this situation I want to allow users to attach Licenses to their user accounts. Each will have 4 fields or so and they can have a number of them. It would make sense to me to store them as children. If this is not possible I may need to make a hidden page at root to store them under? Or maybe do a repeater? Link to comment Share on other sites More sharing options...
dragan Posted March 25, 2019 Share Posted March 25, 2019 23 minutes ago, joer80 said: may need to make a hidden page at root to store them under? Or maybe do a repeater? Yes, why not? Or you could add a new field for licenses to the user template, and store the infos directly there? Link to comment Share on other sites More sharing options...
joer80 Posted March 25, 2019 Author Share Posted March 25, 2019 I was not aware that it is discouraged to put children under user pages. What is the reasoning? I am curious if the same reasoning would apply to using a repeater on user pages or are they encouraged? I can do a hidden page at home if both are discouraged but I would rather not since there is the chance of things becoming out of sync. ie. If you delete a user manually, it is not going to automatically delete the hidden root pages that belong to him that are detached. Link to comment Share on other sites More sharing options...
dragan Posted March 25, 2019 Share Posted March 25, 2019 6 minutes ago, joer80 said: I was not aware that it is discouraged to put children under user pages I guess it has to do with security. Since the user is a system-template, there are mechanisms (limitations) in place that potentially try to stop you from doing something that may sooner or later break stuff. Link to comment Share on other sites More sharing options...
dragan Posted March 25, 2019 Share Posted March 25, 2019 It's odd: If you try to add a child-page under Access > Users > usernameX > Tab "Children", you get these errors as posted above. However, you can create child-pages via the page-tree without a problem! Link to comment Share on other sites More sharing options...
Autofahrn Posted March 25, 2019 Share Posted March 25, 2019 At least adding fields to the user template is pretty uncomplicated and straightforward. I did this a lot in my forum implementation, the user template looks like this: Link to comment Share on other sites More sharing options...
adrian Posted March 25, 2019 Share Posted March 25, 2019 1 hour ago, joer80 said: In this situation I want to allow users to attach Licenses to their user accounts. Each will have 4 fields or so and they can have a number of them. It would make sense to me to store them as children. What about a repeater field on the User template? Or perhaps even a Profields Table field (if you have it). Link to comment Share on other sites More sharing options...
joer80 Posted March 25, 2019 Author Share Posted March 25, 2019 19 minutes ago, adrian said: What about a repeater field on the User template? Or perhaps even a Profields Table field (if you have it). That is probably what I will try next just so if a user is removed, I know the dependant pages will also be! I just was not sure why the children method was not working and if I am not suppose to do it that way, if repeaters would be any safer. 38 minutes ago, dragan said: It's odd: If you try to add a child-page under Access > Users > usernameX > Tab "Children", you get these errors as posted above. However, you can create child-pages via the page-tree without a problem! Good find! If I do it via api, it would probably work also... Link to comment Share on other sites More sharing options...
adrian Posted March 25, 2019 Share Posted March 25, 2019 The other option might be to make use of the alternate user template approach outlined here: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users Link to comment Share on other sites More sharing options...
joer80 Posted March 25, 2019 Author Share Posted March 25, 2019 12 minutes ago, adrian said: The other option might be to make use of the alternate user template approach outlined here: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users That is very interesting looking. I will look into this... I have a feeling the issue with adding children is because the user template is under the admin tree and it wants to use it like a process. Maybe this would let me pull it out of the admin tree? Not sure yet. Link to comment Share on other sites More sharing options...
Gideon So Posted March 26, 2019 Share Posted March 26, 2019 Hi, The alternate user template approach @adrian mentioned is the way to go. Actually, it really depends on what you want to do. For me, I added fields to the user template and it is good enough for me. I put a page reference field in the user template and another field in some other template that need to store user id. Then connect the two page reference fields with the connect page fields module. It works great for me. Gideon Link to comment Share on other sites More sharing options...
joer80 Posted March 26, 2019 Author Share Posted March 26, 2019 26 minutes ago, Gideon So said: Hi, The alternate user template approach @adrian mentioned is the way to go. Actually, it really depends on what you want to do. For me, I added fields to the user template and it is good enough for me. I put a page reference field in the user template and another field in some other template that need to store user id. Then connect the two page reference fields with the connect page fields module. It works great for me. Gideon does using the connect page fields module like that make it so deleting a user removes the other page also? Link to comment Share on other sites More sharing options...
Gideon So Posted March 26, 2019 Share Posted March 26, 2019 2 hours ago, joer80 said: does using the connect page fields module like that make it so deleting a user removes the other page also? Yes. You can try it out yourself. Gideon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now