Jump to content

Recommended Posts

Posted

Hello,

I'm using FormTemplateProcessor module to dynamically create pages and save data.

But for some reason, it's not showing title field in the form that's being rendered on the front-end.

Also when the page is being created, right now, it's auto-generating some name, I'd like it to have title.

I want to know how to

  1. Get title in the front-end form & save it along with the rest of the data.
  2. Save page with its name rather than auto-generated name.

Thanks in advance.

Posted

Hi, Vineonardo. You should remove 'title' item from the array on the line 80 of the module:

$this->set('skipFields', array('title'));
  • Like 1
Posted

I haven't used that module, but it looks like it is focused on processing a contact form. So the name of the page is being autogenerated as a datetime stamp ($this->contact->name = date('y-m-d-H-i-s-u');) so it is unique to each user's contact submission - the title is not really relevant for this purpose as I see it. 

If you want to save user generated content as a page, I would recommend this as a starting point:

http://processwire.com/talk/topic/59-module-want-form-builder/?p=11639

You can use the title that the user enters and use it for the page's name.

Hope that helps.

  • Like 1
Posted

Thanks adrian for your reply.

I checked the link but since I'm not a great programmer, I find it bit hard to use. :P

So, I went on checking the FormTemplateProcessor module and changed the line 192.

I replaced datetime stamp with the field title.

So it works for me :D

I don't know how proper is this but it kinda gets my work done.

I'd like to hear from experts if this is the right way.

Thank you all.

Posted

Remember to sanitize you title:

$sanitizedTitle = $sanitizer->pageName($this->contact->title)
$this->contact->name =  $sanitizer->pageName($this->contact->title);

@Ardian: yes, totally right, it's necessary to check if the page with this name already exists or eliminate errors by adding a numerical suffix.

Posted

@slkwrm & @adrian,

thank you, yes I'll make sure sanitize the input.

@adrian, about the duplicate names, actually, I wish to store username as the name of the page created. Username should be unique. Also there should be a way to check if the username is taken. Can we do this in anyway?

Posted

Does the person creating the page need to have an existing username? That would avoid the need to check.

If not, less us know - there are options, but don't want to go too far down that road if you will be using the username of an already logged in user.

Posted

Ok, I saw some other posts from you about this. Did you end up using some of the code from this post:

http://processwire.com/talk/topic/126-anybody-did-user-registrationlogin/?p=4812

Depending on your needs, you could add additional fields to the user template, rather than needing a separate page.

Regardless, when the form is submitted you need to check for the existence of the username. If it already exists, return the error and get them to enter a different name. If it doesn't exist, save the user and if you need, add the new page using their new username for the page name. Probably stating the obvious here though.

I assume you already have the front-end user registration form working? It sounds to me like you might be better served by extending that to add the page, rather than using the FormTemplateProcessor module. Maybe if you post the code you currently have it might make it easier to add the required functionality.

  • Like 1
Posted

Short answer: No, I didn't.

Long answer: I checked that post numerous times but I'm lazy, I always look for simple solutions just because I'm a front-end designer guy, not a hardcore programmer so I just used FrontUserProfiles module by Khan and it seemed to work good. But now, I've a problem that I need to store users' purchase history and few other user specific details.

So Yes, I already have the registration & log in system working.

I don't know if I can add additional fields to user template, if I can, then that'd be great. I think the better thing to do now would be finding a way add additional fields to user template.

I'd love to share the code with you but I've no idea exactly which part of code I need to share.

And thank you, I really appreciate your time & help. :)

Posted

You can have your user's page name the same as the user name. Not unique names can cause problems only when we talk about the pages belonging to the same parent.

You can always check if the page name is unique using something like:

if (!$pages->find("parent=$myParent, name=$myPageName, include=all")->count()) {

 //the page with this name doesn't yet exist within specified parent so it's safe to add myPage under myParent...

} 
 

Yes, you can extend user template with additional fields. Just go to templates and choose to show system templates in the filter option.

  • Like 2
Posted

I had forgotten about that module. If you want to go the route of adding new fields to the user template, that is easy. Just go to templates and click on filters and show system templates. Then you can add any new fields you want to the user template. 



@slkwrm - your edit stole my thunder :)

  • Like 2
Posted

Oh wow, that's nice.

I didn't know we could edit system templates this way, lovely!

So I guess no need to add page for every user.

But still I'd like to ask both of you if you think using the FrontendUserProfiles module is a good idea to manage users and use this module for production level?

Since I'm no expert, I'd like to know your view on this.

Again, very grateful to both of you. :)

Posted

A posibility I also use is have a page field reference added to the user template and reference the userpage there. Makes it easy to setup and you dont have to care about names as it's already checking for unique username.

  • Like 2
Posted

I have never used it, but I don't see why not - it has been listed as stable and if it's doing what you want you should be fine. Soma will have a better idea though :)

Posted

@Soma, thanks for your reply.

(Please bear with me) So what I should do is add a pagefield to user template which lets say refers to member page which we create after a successful sign up, right?

Posted

Yes exactly. The pseudo user page can be anywhere and you could add children pages for all kind of things. And only a couple field like prename lastname to the real user template. You dont have to it's up to you. I also think you're creative enough to already see what is possible it's more the code you worry. Let me say in PW it'S REALLY no rocket sience compared to other systems and just keep trying to go with the simple API. Once you learned that you'll do anything with ease. :-) Maybe I'm too modest but I'm also not a hardcore programmer but a design guy, and learned a whole lot with PW. Of course I got some background and did a lot with php. You're in good hands with the guys here.

  • Like 4
Posted

Such kind & sweet words!

I can't thank enough to you guys, not only do you help people like me to do something that we can only dream but also support & understand us.

This very thing, the flexibility that PW provides is what allows me to make websites which I could never even think of before.

It's easy to learn & work with PW provided you know what to look for & where. I've just basic knowledge of php which also I learnt just to work with ProcessWire, cause I had understood the potential of PW a while ago but I really started using just a few months back.

So the topic is solved, I'll continue with FrontendUserProfiles module & add pages for users to store additional information.

Thank you all once again. PW & this forum rocks!!!

  • Like 2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...