Support

  1. morgan_leecy
  2. Support
  3. Tuesday, September 12 2017, 11:11 AM
I am using a select box that is linked to a table in my component, and is mutli-select, value is the id (integrer) and label is the name of the item (string)

When I use JsnUser object to retrieve the field, it obviously returns the array of integrers. Is there a way to make JSN look up the labels or do I just have to write a model that uses the array of values in SQL i.e


$user=JsnHelper::getUser();

SELECT item_name
FROM table
WHERE id IN $user->my_list_of_items;

admin Accepted Answer
Admin
Hi,
sorry for late reply, unfortunately the only way is to get labels from DB; labels are stored in table "#__jsn_fields" column "params".

You can use this code to retrieve Label:


// PUT OPTIONS IN AN ARRAY
$db = JFactory::getDbo( ) ;
$query = $db->getQuery( true ) ;
$query->select('params')->from( '#__jsn_fields' )->where( 'alias = "employment"' ) ;
$db->setQuery( $query ) ;
$field_params = json_decode( $db->loadResult( ) ) ;
$field_options = explode( "\n",$field_params->select_options ) ;
$field_options_array = array () ;
foreach( $field_options as $opt ) {
$opt_tmp = explode( '|', $opt );
$field_options_array[ $opt_tmp[ 0 ] ] = $opt_tmp[ 1 ];
}

// SHOW LABEL
echo $field_options_array[ $user->employment ] ;

  1. more than a month ago
  2. Support
  3. # 1
  • 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.