Support

  1. wilbert
  2. General
  3. Thursday, August 24 2017, 04:35 PM
The options of a select field needs to be shown in a list on the profile page shown for public.
Now it shows in a row seperated by a komma.

How to change
admin Accepted Answer
Admin
Hi,
this is not possible natively, but you can use same method at https://www.easy-profile.com/support/input-will-be-shown-as-a-list.html

You can add in function "triggerProfileUpdate" something like:

$options = (array) json_decode( $data[ 'select_alias_field' ] );
if ( is_array( $options ) && count( $options ) ) {
$content = '<ul>';
foreach( $options as $option ) {
$content .= '<li>' . $option . '</li>';
}
$content .= '</ul>';
$data[ 'textarea_field_alias' ] = $content;
}
else $data[ 'textarea_field_alias' ] = '';


NOTE: This code is not tested and not supported, this is only for example purpose.
  1. more than a month ago
  2. General
  3. # 1
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Have you replaced "select_alias_field" with alias of your select field and "textarea_field_alias" with the alias of your textarea field?
  1. more than a month ago
  2. General
  3. # 3
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 4
admin Accepted Answer
Admin
Hi,
there are different ways to make this, the most simple is to add an array with association between value and text of options, for example:

$texts = array(
'value1' => 'text1',
'value2' => 'text2',
'value3' => 'text3',
);


of course you need also to change function that creates list items, so it become

$content .= '<li>' . $text[ $option ] . '</li>';
  1. more than a month ago
  2. General
  3. # 5
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 6
admin Accepted Answer
Admin
the functions could be something like this:

$texts = array(
'value1' => 'text1',
'value2' => 'text2',
'value3' => 'text3'
);
$options = (array) json_decode( $data[ 'select_alias_field' ] );
if ( is_array( $options ) && count( $options ) ) {
$content = '<ul>';
foreach( $options as $option ) {
if( isset( $text[ $option ] ) ) $content .= '<li>' . $text[ $option ] . '</li>';
}
$content .= '</ul>';
$data[ 'textarea_field_alias' ] = $content;
}
else $data[ 'textarea_field_alias' ] = '';
  1. more than a month ago
  2. General
  3. # 7
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 8
admin Accepted Answer
Admin
Hi,
yes, there is a small error in my code, replace this:

if( isset( $text[ $option ] ) ) $content .= '<li>' . $text[ $option ] . '</li>';

with this:

if( isset( $texts[ $option ] ) ) $content .= '<li>' . $texts[ $option ] . '</li>';
  1. more than a month ago
  2. General
  3. # 9
wilbert Accepted Answer
Pro
hmmm still not working. I also see no text int the editor ( in the first one, which was working i saw some text there)
Maybe this helps you to solve

see attachment
  1. more than a month ago
  2. General
  3. # 10
admin Accepted Answer
Admin
Hi,
my code is only for example purpose, you need to change values in the array with values and text of select field.

$texts = array(
'value_for_option1' => 'Regisseur',
'value_for_option2' => 'Technicus',
......
);
  1. more than a month ago
  2. General
  3. # 11
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 12
admin Accepted Answer
Admin
Hi,
you need also to replace value_for_option0, value_for_option1,... with values from your select fields, for example if you have options like:

music|Music
art|Art

then array will be


$texts = array(
'music' => 'Music',
'art' => 'art'
)
  1. more than a month ago
  2. General
  3. # 13
wilbert Accepted Answer
Pro
Content Protected
  1. more than a month ago
  2. General
  3. # 14
admin Accepted Answer
Admin
Hi,
only thing.. when there will be an option added, i need to change the skeleton.php either..
Yes, you should add the new option in the skeleton.php file, there is also another way to make it dynamically but it is too complex.
  1. more than a month ago
  2. General
  3. # 15
wilbert Accepted Answer
Pro
I like to do this the same for a checkboxlist.
But it seems i have to change the code a little bit
Can you tell me how?


class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{
$texts = array(
'0' => 'Acteur',
'1' => 'Voice-over',
'2' => 'Vertaler',
'3' => 'Regisseur',
'4' => 'Technicus'
);
$options = (array) json_decode( $data[ 'test3' ] );
if ( is_array( $options ) && count( $options ) ) {
$content = '<ul>';
foreach( $options as $option ) {
if( isset( $texts[ $option ] ) ) $content .= '<li>' . $texts[ $option ] . '</li>';
}
$content .= '</ul>';
$data[ 'test3_text' ] = $content;
}
else $data[ 'test3_text' ] = '';
}
}

  1. more than a month ago
  2. General
  3. # 16
admin Accepted Answer
Admin
Hi,
the code is the same, you should change options array (value and title) and alias of field (so from "werkzaamheden" to checkbox field alias)
  1. more than a month ago
  2. General
  3. # 17
wilbert Accepted Answer
Pro
I have let the options the same (copied them) and changed the alias..
But it doesnot work.

You are sure this works the same as for checkboxlist as slectionfield?
  1. more than a month ago
  2. General
  3. # 18
wilbert Accepted Answer
Pro
These are the options in my text3 checkboxfield
0|Acteur
1|Voice-over
2|Vertaler
3|Regisseur
4|Technicus
  1. more than a month ago
  2. General
  3. # 19
wilbert Accepted Answer
Pro
It is owkring now, it doesnot work for existing users, but now it works..
  1. more than a month ago
  2. General
  3. # 20
admin Accepted Answer
Admin
it doesnot work for existing users
this is an expected behavior, triggers are launched when you register or edit a profile.
  1. more than a month ago
  2. General
  3. # 21
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.