<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Uri\Uri;
if (!file_exists(JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php') ||
!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed';
return;
}
$userid = '[user_id]';
$token = '[cb_token_api]';
$ndata = [
'userid' => $userid,
'command' => 'getNdbModelsCommand'
];
$url = Uri::base() . 'devhandle-command';
$http = HttpFactory::getHttp();
$options = [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $token
]
];
$response = $http->post($url, json_encode($ndata), $options);
$data = json_decode($response->body, true);
if (isset($data['data']) && is_array($data['data'])) {
$models = [];
foreach ($data['data'] as $model) {
$models[] = $model;
}
var_dump($models);
} else {
echo 'No data received or error';
var_dump($data);
}
Please Log in to join the conversation.
Those are for static options. Code based options are added under Parameters > Code. That fieldtype allows you to combine static options with code based ones.Could you tell me what is needed in the value/label of the global tab in order to get the data to be displayed ?
return array( 'Value' => 'Label' );
return array( '1', '2', '3', '4', '5' );
return array( '1' => 'Value 1', '2' => 'Value 2', '3' => 'Value 3', '4' => 'Value 4', '5' => 'Value 5' );
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Uri\Uri;
if (!file_exists(JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php') ||
!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed';
return;
}
// $token = '[cb_token_api]';
//$ndburl = '[cb_neuraldb]';
$ndata = [
'ndb_url' => $ndburl,
'token' => $token
];
$url = Uri::base() . 'py/getNeuralDBModels';
$http = HttpFactory::getHttp();
$options = [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
]
];
$response = $http->post($url, http_build_query($ndata), $options);
$data = json_decode($response->body, true);
if (isset($data['data']) && is_array($data['data'])) {
$models = [];
foreach ($data['data'] as $model) {
$models[] = ['Value' => $model, 'Label' => $model];
}
return $models;
}
Please Log in to join the conversation.
That is not the format provided above. Please read my reply carefully as examples have been provided.$models[] = ['Value' => $model, 'Label' => $model];
No, it's an issue with your code. You're setting every option to have the same value. Below is the expected format.So my question is : maybe that receiving only one value is an issue for CB code dropdown single select field ?
return array( 'Value' => 'Label' );
return array( '1' => 'Opt 1', '2' => 'Opt 2' );
Please Log in to join the conversation.