Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi,

I am using data bound form with member module. I create two nos. different data-bound clonable form one is for employer and other one for employee. after register and login employer can post jobs and employee can post resume. I give a option to employer to set expire date for every jobs they posting. so, no mode='edit' require employer.

But employee can create and update there resume any time , so I decide to place all editable region for employee on members_tpl 'members/index.php' , but I cant do this because it will effect new registration process for employer.

So, I decide create two different page for employee one is create.php and edit.php
but I realize I cant dynamic relate member Id and page Id for editing .



How do I solve this problem ? I need your guidance .

Thanks
Subhamoy
Subhamoy,

If I understood it correctly, the problem is that both 'employers' and 'employees' are cloned-pages of 'members/index.php'. However, the two require different sets of editable regions - specifically the employees require more regions than the employers - so you cannot define all the regions within the members template.

So now, perhaps, you are using an additional template for employees to hold data (i.e. editable regions) specific to them.

Is that correct?

If so, could you please tell me exactly how do you offer the regions from the two templates to the employees?

I mean, the first instance would be the registration form itself - do you show here only regions from members template or are you trying to show regions from both templates here?

More likely, during registration you show only regions from members template and then when the employee is registered you offer her another screen where she can edit regions from the second template.

Please clarify the points and then we can discuss about the solution.

Thanks.
Hi KK Sir,
Subhamoy,

If I understood it correctly, the problem is that both 'employers' and 'employees' are cloned-pages of 'members/index.php'. However, the two require different sets of editable regions - specifically the employees require more regions than the employers - so you cannot define all the regions within the members template.

So now, perhaps, you are using an additional template for employees to hold data (i.e. editable regions) specific to them.

Is that correct?


Yes it correct. and now I offer employee (if possible employer also) they can edit there submitted data using mode='edit' when after they login.

specifically the employees require more regions than the employers

employees require more and or some different regions than the employers

I mean, the first instance would be the registration form itself - do you show here only regions from members template or are you trying to show regions from both templates here?


Employer and employee can register with screen name, email address and password,
after registration success they can click postjob.php or postresume.php
here they can submit ( I already code this, and its works) and edit (here I cant configure how to dynamically add page id) there data .


Thanks
Hi Subhamoy,

Apologies for the delay in posting the solution.
Coming to which -

One solution to this problem could be to simply define *all* editable regions within the members template itself. So although many of the fields won't be applicable to 'employers', nevertheless those would be present in the template.

While offering the fields for editing through the databound form, we can test if it is the 'employer' account or the 'employee' and then show the extra fields only if it is the employee editing her record.

One potential problem with this approach could be if any of those extra fields is 'required' - this will crop up when the 'employer' is editing her record. Since we would have hidden the extra fields here, the required field will remain empty and the save operation will fail.

Although the problem can be solved using a workaround mentioned here - viewtopic.php?f=4&t=9118, let us continue the tack you have taken i.e. use a separate template to hold data only for the employees.

We'll begin with a clonable template (say, named 'extra.php').
Define all the extra regions you'd want for the employees in this template.

For each employee page in the members template, we'll want to have a counterpart page in this new template.
This is a classical 'one-to-one' relation between pages.

Although we can use 'relation' feature of Couch to establish this relationship between the two templates (members and extra), we can actually get by without that additional hassle.

Since a page's name (k_page_name) is always a unique identifier, if we could ensure that for a page in member's template, we have a page with the *same name* in the extra template that would be sufficient to establish the relationship.

So, for example, suppose a member named 'john_doe' is logged in and is editing his profile.
We can check if a page named 'john_doe' is present in the extra template. If it is, we can offer that page for editing as DataBound Form.

What happens if no such page is present? (this will happen the first time a member edits her profile).
In that case, we'll set the 'mode' parameter of the Datbound Form to 'create'.
This will create a new page when the form is submitted. We'll just make sure that the name (and, although not essential, the title of the new page matches that of the logged-in member).

The following code does just that.
Add this form to the profile page (so we'll now have two forms on the profile page - the original will edit fields from the members template and the new form will edit those of the extra template).
Code: Select all
<!-- find if the member has an associated page in the template for extra info -->
<cms:set my_form_mode = 'create' 'global' />

<cms:pages masterpage='extra.php' page_name=k_member_name limit='1' show_future_entries='1' >
    <cms:set my_page_id = k_page_id 'global' />
    <cms:set my_form_mode = 'edit' 'global' />
</cms:pages>

<cms:show my_form_mode />

<!-- this is regular databound-form showing fields from the extra template -->
<cms:form
    masterpage='extra.php'
    mode=my_form_mode
    page_id=my_page_id
    enctype="multipart/form-data"
    method='post'
    anchor='0'
    >
   
    <cms:if k_success >
        <cms:db_persist_form
            k_page_name = k_member_name
            k_page_title = k_member_title
        />

        <cms:if k_success >   
            <cms:set_flash name='success_msg' value='1' />
            <cms:redirect k_page_link />
        </cms:if>
    </cms:if> 
   
    <cms:if k_error >
        <font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
    </cms:if>
   
    <!-- an example extra field -->
    <cms:input name='seminar_date' type='bound' /><br />
   
    <input type="submit" name="submit" value="Save"/>   
   
</cms:form>   

Please note in the code above how we change the 'mode' of the form from 'create' to 'edit' if there is an existing page for the member and how we are explicitly setting the new page's name and title to match the member's info.

Hope it helps.
Hi KK Sir,

A REALLY BIG THANK YOU

I COULDN'T DO THIS WITHOUT YOUR SUPPORT,
WITH HEARTFELT GRATITUDE

subhamoy
You are welcome Subhamoy :)
I'm glad I could help.
6 posts Page 1 of 1