Well, thanks for anyone who tried to help. Really appreciated.
I'll try to explain it in a way that I would like to have when searching for such a thing like this.
The solution was in the way that
nested elements work.
First we need to understand how a nested element works (the most practical way. I am doing my best to explain, I am not very good with words, sorry).
In this case, the element in question is
<fieldset>.
The custom XML file, with extra fields information, has two fieldsets, but the Profile Page is loaded bringing one more fieldset element, the one with the main profile information. The main Profile information will be available for both: internal users and customers.
Let's see how:
PROFILE PAGE PARTIAL CODE:
Code: Select all
<form id="member-profile" class="form-validate form-horizontal well" action="/forms/customers-profile?task=profile.save" method="post" enctype="multipart/form-data">...event...
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<div class="...... the code continues
The second and third fieldsets occurences are the ones from my custom XML.
This is how a nested fieldset happens, in this case.
The CSS for nested elements is:
element:nth-child(number of the occurence)
So, if we want to change the color attribute for the second fieldset occurence, the command would be:
Code: Select all
fieldset:nth-child(2) {
color: red;
}
Now I can control which fieldset block will be available.
In the Joomla menu manager, I've created two menu items:
1 - Internal Users Edit Profile:
- Set the "page class", in "page display" with " internal_users_menu" value;
- Set access level to Local Users Access Level policy.
2 - Customers Edit Profile:
- Set the "page class", in "page display" with " customer_menu" value;
- Set access level to Customers Access Level policy.
This is how I can control what will happen when each menu item is accessed by the users.
CUSTOM EXTRA FIELDS XML FILE
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="ldap_profile">
<fieldset
name="personal"
label="PLG_LDAP_PROFILE_FIELDSET_PERSONAL_LABEL"
id="personal"
>
<field
name="homePhone"
type="text"
description="PLG_LDAP_PROFILE_FIELD_RG_DESC"
label="PLG_LDAP_PROFILE_FIELD_RG_LABEL"
size="30"
required="false"
readonly="false"
sync="true"
/>
<field
name="pager"
type="text"
description="PLG_LDAP_PROFILE_FIELD_CPF_DESC"
label="PLG_LDAP_PROFILE_FIELD_CPF_LABEL"
size="30"
required="false"
readonly="false"
sync="true"
/>
</fieldset>
<fieldset name="personal_read_only"
label="PLG_LDAP_PROFILE_FIELDSET_PERSONAL_LABEL"
>
<field
name="homePhone"
type="text"
description="PLG_LDAP_PROFILE_FIELD_RG_DESC"
label="PLG_LDAP_PROFILE_FIELD_RG_LABEL"
size="30"
readonly="true"
sync="true"
/>
<field
name="pager"
type="text"
description="PLG_LDAP_PROFILE_FIELD_CPF_DESC"
label="PLG_LDAP_PROFILE_FIELD_CPF_LABEL"
size="30"
readonly="true"
sync="true"
/>
</fieldset>
</fields>
</form>
As you can see, there are two fieldsets, one that will be editable and another one that will be readonly.
The editable part of the XML will be used in the backend, so administrators will be able to update these fields.
The readonly block will be available to internal users only.
Customers will never see any of these additional fields.
I also had to hide some fields from internal users and all fields from customers in the
Profile view page. This page has a buttom to Edit the profile.
CSS TO CONTROL THE VIEWING:
Code: Select all
/* hides the editable fieldset from internal users in the edit Profile page*/
.internal_users_menu div.profile-edit #member-profile fieldset:nth-child(2),
/* hides the editable fieldset from internal users in the view Profile page*/
.internal_users_menu .users-profile-custom-personal legend,
.internal_users_menu .users-profile-custom-personal dl,
.internal_users_menu .users-profile-custom-personal dt,
/* hides all extra fields fieldsets from customers in the edit Profile page*/
.customer_menu div.profile-edit #member-profile fieldset:nth-child(2),
.customer_menu div.profile-edit #member-profile fieldset:nth-child(3),
/* Hides all extra fields fieldsets from customers in the view Profile page */
.customer_menu .users-profile-custom-personal legend,
.customer_menu .users-profile-custom-personal dl,
.customer_menu .users-profile-custom-personal dt,
.customer_menu .users-profile-custom-personal_read_only legend,
.customer_menu .users-profile-custom-personal_read_only dl,
.customer_menu .users-profile-custom-personal_read_only dt
{
display: none;
}
Now when the internal user logs in, only the first fieldset (the one with the main profile information) and the third fieldset (the readonly one) will be available. And when a customer logs in, only the first fieldset (the one with the main profile information) will be available.
This is just a workaround, because it's important to understand that the fieldsets are processed and are available, just not visible.
Yeah... a little bit too much of information, I know. But if I had found something like this when I had this need, it would be great! Not only it would have teach me something, but also would have helped me, and saved two weeks of searching.