Share » Forums » Developer » Problem Customising the user edit page

Problem Customising the user edit page

Problem Customising the user edit page

Tuesday 31 August 2004 12:19:59 pm - 2 replies

Author Message

Eivind Marienborg

Friday 03 September 2004 12:51:10 am

I'm not sure about what you're trying to acheive, but here's how I create my custom edit-pages.

You need to create an override for content/edit.tpl (the main edit page), and content/edit_attribute.tpl (the template handling each line/input field).

Modify your content/edit.tpl-override:
Create a CSS-class hiding the validation and placement bar at the top (this seems to be needed by eZ), and comment out the "right part" in your template.

Here's my working code for the altered parts:

<div class="noshow">
    {include uri="design:content/edit_validation.tpl"}

    {include uri="design:edit_placement_user.tpl"}
    <br/>
</div>
{*
    <!-- Right part start-->
    {include uri="design:content/edit_right_menu.tpl"}
    <!-- Right part end -->
*}

In order to change the way each input field is outputted (and the entire look and feel of the page), you need to edit the content/edit_attribute.tpl-override. Add a switch matching on the field title, and a case for the ones you want to change, and leave the default in the default case-block.

It might seem troublesome, but it works nicely.

Eivind

Joe Wolf

Friday 03 September 2004 6:18:20 am

Thanks Eivind,

Basically I want to have a fully customised user edit page that doesn't rely on Ez's attribute_edit_gui. This is because I don&acute;t want all forms on the site to look exactly the same. This has meant building my own page lifting code from the edit datatype tpls (e.g. content/datatype/edit/ezstring.tpl)

This means that my edit.tpl looks looks this:

<form enctype="multipart/form-data" name="Edit" method="post" action={concat("/user/edit/", $current_user.contentobject_id,"/",$current_user.contentobject.current_version)|ezurl}>
        <tr class="FormRow"> 
          <td width="130" class="TxtFormDescription"> {'Title'|i18n('justlanded')} 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm"> 
			  	{section name=title loop=$user.data_map.title.content.enum_list}
					<input type="hidden" name="ContentObjectAttribute_data_enumid_{$current_user.contentobject.data_map.title.id}[]" value="{$title:item.id}" />
					<input type="hidden" name="ContentObjectAttribute_data_enumvalue_{$current_user.contentobject.data_map.title.id}[]" value="{$title:item.enumvalue}" />  
					<input type="hidden" name="ContentObjectAttribute_data_enumelement_{$current_user.contentobject.data_map.title.id}[]" value="{$title:item.enumelement}" />
					<input type="radio" name="ContentObjectAttribute_select_data_enumelement_{$current_user.contentobject.data_map.title.id}[]" value="{$title:item.enumelement}" 
				  	{section name=current_title loop=$current_user.contentobject.data_map.title.content.enumobject_list}
				  	{switch match=$title:item.enumelement}
						{case match=$title:current_title:item.enumelement}
				   		checked
						{/case}
						{case}
						{/case}
				  	{/switch}					
				 	{/section}
					/> {$title:item.enumelement}
				 {/section}
				 </td>
              </tr>
			</table>  
            </td>
        </tr>
        <tr class="FormRow"> 
          <td width="130" class="TxtFormDescription"> {'First name'|i18n('justlanded')} 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.first_name.id}" />
				<input type="text" class="InputRed" name="ContentObjectAttribute_ezstring_data_text_{$current_user.contentobject.data_map.first_name.id}" style="width:100%;" value="{$current_user.contentobject.data_map.first_name.data_text}"> 
                </td>
              </tr>
            </td>
          </table>
		</tr>
        <tr class="FormRow"> 
          <td width="130" class="TxtFormDescription"> {'Surname'|i18n('justlanded')} 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.sur_name.id}" />
				<input type="text" class="InputRed" name="ContentObjectAttribute_ezstring_data_text_{$current_user.contentobject.data_map.sur_name.id}" style="width:100%;" value="{$current_user.contentobject.data_map.sur_name.data_text}"> 
                </td>
              </tr>
            </td>
		  </table>
        </tr>
        <tr class="FormRow"> 
          <td width="130" class="TxtFormDescription"> {'Email'|i18n('justlanded')} 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.user_account.content.email.id}" />  
				<input type="text" class="InputRed" name="ContentObjectAttribute_data_user_email_{$current_user.contentobject.data_map.user_account.content.email.id}" style="width:100%;" value="{$current_user.contentobject.data_map.user_account.content.email}">                
				</td>
              </tr>
		  </table>  
          </td>
        </tr>
        <tr class="FormRow"> 
          <td width="130" class="TxtFormDescription"> {'User name'|i18n('justlanded')} 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.user_account.content.login.id}" />
				<input type="text" class="InputRed" name="ContentObjectAttribute_data_user_login_{$current_user.contentobject.data_map.user_account.content.login.id}" style="width:100%;" value="{$current_user.contentobject.data_map.user_account.content.login}">
                </td>
              </tr>
          </table>
		  </td>
        </tr>
      </table>
	  </td>
  </tr>
  <tr> 
    <td height="12"><img src={"blind.gif"|ezimage} width=1 height=12 alt="" border="0"></td>
  </tr>
  <tr> 
    <td> 
      <!--country details-->
      <table class="FormBg" width="100%" border="0">
        <tr class="FormRow"> 
          <td width="180" class="TxtFormDescription""> {'Your Home Country'|i18n('justlanded')}? 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.country.id}" />
				<select class="box" name="ContentObjectAttribute_ezcountry_data_text_{$current_user.contentobject.data_map.country.id}" value="{$current_user.contentobject.data_map.country.data_text}">
				{include selected_option=$current_user.contentobject.data_map.country.data_text uri='design/standard/templates/content/datatype/edit/ezcountry_options.tpl' name='country_options'}
				</select>  
                </td>
              </tr>
            </table></td>
        </tr>
        <tr class="FormRow"> 
          <td width="180" class="TxtFormDescription"> {'Your Just Landed Country'|i18n('justlanded')}? 
          </td>
          <td> 
		  <table cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td class="TxtForm">
				<input type="hidden" name="ContentObjectAttribute_id[]" value="{$current_user.contentobject.data_map.jlcountry.id}" />
				<select class="box" name="ContentObjectAttribute_ezcountry_data_text_{$current_user.contentobject.data_map.jlcountry.id}" value="{$current_user.contentobject.data_map.jlcountry.data_text}">
				{include selected_option=$current_user.contentobject.data_map.jlcountry.data_text uri='design/standard/templates/content/datatype/edit/ezcountry_options.tpl' name='country_options'}
				</select>  
                </td> 
                </td>
              </tr>
            </table>
			</td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="12"><img src={"blind.gif"|ezimage} width=1 height=12 alt="" border="0"></td>
  </tr>
  <tr> 
    <td> 
      <!--age-->
      <table class="FormBg" width="100%" border="0">
        <tr class="FormRow"> 
          <td class="TxtFormHeadline"> {'Age'|i18n('justlanded')}? 
          </td>
        </tr>
        <tr> 
          <td class="TxtForm">
		  {section name=age loop=$user.data_map.age.content.enum_list}
				<input type="hidden" name="ContentObjectAttribute_data_enumid_{$current_user.contentobject.data_map.age.id}[]" value="{$age:item.id}" />
				<input type="hidden" name="ContentObjectAttribute_data_enumvalue_{$current_user.contentobject.data_map.age.id}[]" value="{$age:item.enumvalue}" />  
				<input type="hidden" name="ContentObjectAttribute_data_enumelement_{$current_user.contentobject.data_map.age.id}[]" value="{$age:item.enumelement}" />
				<input type="radio" name="ContentObjectAttribute_select_data_enumelement_{$current_user.contentobject.data_map.age.id}[]" value="{$age:item.enumelement}" 
				{section name=current_age loop=$current_user.contentobject.data_map.age.content.enumobject_list}
					{switch match=$age:item.enumelement}
						{case match=$age:current_age:item.enumelement}
				   		checked
						{/case}
				  	{/switch}
				 {/section}
				  /> {$age:item.enumelement}
			{/section}
		  </td>
        </tr>
        <!--occupation-->
        <tr class="FormRow"> 
          <td class="TxtFormHeadline"> {'Occupation'|i18n('justlanded')}? 
          </td>
        </tr>
        <tr> 
          <td class="TxtForm">
		  {section name=occupation loop=$user.data_map.occupation.content.enum_list}
				<input type="hidden" name="ContentObjectAttribute_data_enumid_{$current_user.contentobject.data_map.occupation.id}[]" value="{$occupation:item.id}" />
				<input type="hidden" name="ContentObjectAttribute_data_enumvalue_{$current_user.contentobject.data_map.occupation.id}[]" value="{$occupation:item.enumvalue}" />  
				<input type="hidden" name="ContentObjectAttribute_data_enumelement_{$current_user.contentobject.data_map.occupation.id}[]" value="{$occupation:item.enumelement}" />
				<input type="radio" name="ContentObjectAttribute_select_data_enumelement_{$current_user.contentobject.data_map.occupation.id}[]" value="{$occupation:item.enumelement}" 
				{section name=current_occupation loop=$current_user.contentobject.data_map.occupation.content.enumobject_list}
					{switch match=$occupation:item.enumelement}
						{case match=$occupation:current_occupation:item.enumelement}
				   		checked
						{/case}
				  	{/switch}
				 {/section}
				  /> {$occupation:item.enumelement}
			{/section}
			</td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td colspan="2" height="12"><img src={"blind.gif"|ezimage} width=1 height=12 alt="" border="0"></td>
  </tr>
  <tr> 
    <td> <input type="submit" class="InputButton" name="PublishButton" value="{'Submit'|i18n('design/justlanded/user')}" /> 
      <input type="reset" class="InputButton" name="DiscardButton" value="{'Cancel'|i18n('design/justlanded/user')}" /> 
    </td>
  </tr>
</table>
</form>

This pulls in the users details successfully, but now the problem I have is that when I submit this it doesn't publish, but stays as a draft. Any ideas? I might try doing it your way although I'm just learning PHP and therefore if you could give me an example of how to do the switches for each edit datatype in such a way that I can have different ones for different forms, rather than them all being generic, that would be great.

Joe

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu