Hopping some of you can help me with this, since a few days back I'm trying to get a list like a carousel, displayed in my FaceBook bot using the following code:
public function returnCarousel(){
$messagearray = array (
'message' =>
array (
'attachment' =>
array (
'type' => 'list',
'payload' =>
array (
'template_type' => 'list',
'top_element_style' => 'compact',
'elements' =>
array (
0 =>
array (
'title' => 'Classic T-Shirt Collection',
'subtitle' => 'See all our colors',
'image_url' => 'https://peterssendreceiveapp.ngrok.io/img/collection.png',
'buttons' =>
array (
0 =>
array (
'title' => 'View',
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/collection',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
),
),
1 =>
array (
'title' => 'Classic White T-Shirt',
'subtitle' => 'See all our colors',
'default_action' =>
array (
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/view?item=100',
'messenger_extensions' => false,
'webview_height_ratio' => 'tall',
),
),
2 =>
array (
'title' => 'Classic Blue T-Shirt',
'image_url' => 'https://peterssendreceiveapp.ngrok.io/img/blue-t-shirt.png',
'subtitle' => '100% Cotton, 200% Comfortable',
'default_action' =>
array (
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/view?item=101',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
'buttons' =>
array (
0 =>
array (
'title' => 'Shop Now',
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/shop?item=101',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
),
),
),
'buttons' =>
array (
0 =>
array (
'title' => 'View More',
'type' => 'postback',
'payload' => 'payload',
),
),
),
),
),
);
$this->sendMessage($messagearray);
}
public function sendMessage($parameters) {
echo json_encode($parameters);
}
No carousel is displayed and no error is returnes intead I get in my ngrok console this:
{"message":{"attachment":{"type":"list","payload":{"template_type":"list","top_element_style":"compact","elements":[{"title":"Classic T-Shirt Collection","subtitle":"See all our colors","image_url":"https://peterssendreceiveapp.ngrok.io/img/collection.png","buttons":[{"title":"View","type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/collection","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"}]},{"title":"Classic White T-Shirt","subtitle":"See all our colors","default_action":{"type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/view?item=100","messenger_extensions":false,"webview_height_ratio":"tall"}},{"title":"Classic Blue T-Shirt","image_url":"https://peterssendreceiveapp.ngrok.io/img/blue-t-shirt.png","subtitle":"100% Cotton, 200% Comfortable","default_action":{"type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/view?item=101","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"},"buttons":[{"title":"Shop Now","type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/shop?item=101","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"}]}],"buttons":[{"title":"View More","type":"postback","payload":"payload"}]}}}}
if I send a single card it works, please your help
SOLVED: I formatted the array like this and I get it working.
$messagearray = array (
'speech' => 'Carousel',
'messages' => array (
0 => array (
'type' => 1,
'platform' => 'facebook',
'title' => 'Rosa Amarilla',
'imageUrl' => 'http://rosa.com/assets/imgs/rosaamarilla.jpg',
'buttons' =>
array (
0 =>array ('text' => 'Detalles de la Rosa', 'postback' => '',),
),
),
1 =>array (
'type' => 1,
'platform' => 'facebook',
'title' => 'Rosa Azul',
'imageUrl' => 'http://rosa.com/assets/imgs/rosaazul.jpg',
'buttons' =>
array (
0 => array ('text' => 'Detalles de la Rosa', 'postback' => '',),
),
),
),);
Related
I get passed an array in a callback function. Now I want access a value of this array.
I can dump this array into a file with var_export($fields[1], True)
Here is the content of the export:
helper_plugin_bureaucracy_fieldtextbox::__set_state(array(
'mandatory_args' => 2,
'opt' =>
array (
'cmd' => 'textbox',
'label' => 'Kunde',
'display' => 'Kunde',
'value' => 'myimportantdata',
),
'tpl' =>
array (
'_elem' => 'textfield',
'_text' => '##DISPLAY##',
'_class' => '##CLASS##',
'id' => '##ID##',
'name' => '##NAME##',
'value' => '##VALUE##',
'class' => 'edit required',
'required' => 'required',
),
'checks' =>
array (
),
'hidden' => false,
'error' => false,
'checktypes' =>
array (
'/' => 'match',
'<' => 'max',
'>' => 'min',
),
))
I want to access the value of opt->value whitch is 'myimportantdata' in this case.
How can I achieve this?
I already tried:
$mydata = $fields[1]['helper_plugin_bureaucracy_fieldtextbox']['opt'];
$mydata = $fields[1][0][2];
$mydata = $fields[1]->helper_plugin_bureaucracy_fieldtextbox['opt'];
without success :-(
fields[1] contains an object of the type 'helper_plugin_bureaucracy_fieldtextbox'. The access to the properties of the object such as 'opt' must be done with the -> operator.
$opt = $fields[1]->opt;
$opt_value = $fields[1]->opt['value']; //myimportantdata
$data = array(
'mandatory_args' => 2,
'opt' =>
array (
'cmd' => 'textbox',
'label' => 'Kunde',
'display' => 'Kunde',
'value' => 'myimportantdata',
),
'tpl' =>
array (
'_elem' => 'textfield',
'_text' => '##DISPLAY##',
'_class' => '##CLASS##',
'id' => '##ID##',
'name' => '##NAME##',
'value' => '##VALUE##',
'class' => 'edit required',
'required' => 'required',
),
'checks' =>
array (
),
'hidden' => false,
'error' => false,
'checktypes' =>
array (
'/' => 'match',
'<' => 'max',
'>' => 'min',
),
);
echo $data["opt"]["value"];
This question already has answers here:
How can I sort arrays and data in PHP?
(14 answers)
Closed 4 years ago.
How do you make someone who has a higher subscriberCount be sorted to the top? For example, I want to list the top 50 by subscriberCount. Currently it just sorts by the order added to $topchan1["items"]. I need to order by the highest subscriberCount.
$topchan1 = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/channels?id='
.$kanalas1.'&part=snippet%2Cstatistics&key='.$API.''),true);
$videoList = array_merge($topchan1["items"],$topchan2["items"],$topchan3["items"],$topchan4["items"]);
foreach ($videoList as $key => $part) {
$sort[$key] = sort($part['statistics']['subscriberCount']);
}
array_multisort($sort, SORT_DESC, $videoList);
$i = 1;
for( $i = 0 ; $i <= count($videoList)-1 ; $i++ )
{
if(isset($videoList[$i]["statistics"]["subscriberCount"])) {
echo $videoList[$i]["statistics"]["subscriberCount"].' _ ';
}
}
how looks
array ( 0 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/Wj45BU6eiZOcR9nLVG4cXvflUNY"', 'id' => 'UCgQ1CeGtjCbkvslmG3zTAFA', 'snippet' => array ( 'title' => 'ILYA STREKAL', 'description' => 'Привет, меня зовут Илья Стрекаловский, добро пожаловать на мой канал!', 'customUrl' => 'BayanCover', 'publishedAt' => '2013-01-13T15:44:18.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'ILYA STREKAL', 'description' => 'Привет, меня зовут Илья Стрекаловский, добро пожаловать на мой канал!', ), 'country' => 'RU', ), 'statistics' => array ( 'viewCount' => '234688406', 'commentCount' => '0', 'subscriberCount' => '2254032', 'hiddenSubscriberCount' => false, 'videoCount' => '153', ), ),
1 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/1vk-0WWcl2cpv1LO_4WQGsb2Qhk"', 'id' => 'UCMnOYmqiAQhE51l6AzEuOBA', 'snippet' => array ( 'title' => '', 'customUrl' => 'yanshelestx', 'publishedAt' => '2016-01-08T13:06:33.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'defaultLanguage' => 'ru', 'localized' => array ( 'title' => 'Shelest', 'description' => 'Hello! This channel is dedicated to high-tech. I\'m a big lover of quality products for an adequate cost. The channel will express the personal opinion of the purchased goods and to listen to your words. Thank you!', ), 'country' => 'UA', ), 'statistics' => array ( 'viewCount' => '53038697', 'commentCount' => '0', 'subscriberCount' => '404844', 'hiddenSubscriberCount' => false, 'videoCount' => '123', ), ),
2 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/sSeA4B5B1NeVdRrLvhV6IQk9AJs"', 'id' => 'UCEFpNxeybzVwRbnYabQsXEg', 'snippet' => array ( 'title' => 'Bass Music Movement', 'description' => 'Music Promotion & Record Label Submissions/Business inquiries: bassmusicmovement#outlook.com', 'customUrl' => 'brazilianbassmovement', 'publishedAt' => '2017-03-06T02:48:38.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'Bass Music Movement', 'description' => 'Music Promotion & Record Label Submissions/Business inquiries: bassmusicmovement#outlook.com', ), 'country' => 'BR', ), 'statistics' => array ( 'viewCount' => '136215709', 'commentCount' => '0', 'subscriberCount' => '748023', 'hiddenSubscriberCount' => false, 'videoCount' => '46', ), ),
3 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/VwnSAHbLaj-RwQW8QKFECxplCp4"', 'id' => 'UCAf-RYRpQgxpj8voC29ck7w', 'snippet' => array ( 'title' => 'Hard Play', 'description' => '', 'customUrl' => 'hardplaygamechannel', 'publishedAt' => '2016-06-23T20:39:00.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => '', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAyu2XfSQsqjyNqu-fTTjleD9XzLSLoLsP-8Yw=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAyu2XfSQsqjyNqu-fTTjleD9XzLSLoLsP-8Yw=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'Hard Play', 'description' => '', ), 'country' => 'RU', ), 'statistics' => array ( 'viewCount' => '39723260', 'commentCount' => '0', 'subscriberCount' => '784162', 'hiddenSubscriberCount' => false, 'videoCount' => '260', ), ), )
You need to use usort() with custome function where you can compare viewCount and sort array in DESC order
function sortByviewCount($a, $b) {
return ($a['statistics']['viewCount'] > $b['statistics']['viewCount']) ? -1:1;
}
usort($videoList, 'sortByviewCount');
print_r($videoList);
Output:-https://3v4l.org/HqXVc
I have a serialized field in my database. I can get the contents of this field and unserialize them however I am unsure how to get certain values of these. I ultimately need a foreach of each item and value from the data.
In the below example I need to be able to get the following:
Main Image Replacement:
BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG Complimentary:
Comp Text Quote Code: Code Text
I need the label as one variable and the value as another within a foreach. These labels and values are variable so I cannot manually get this data by their labels.
array (
0 =>
array (
'mode' => 'builder',
'cssclass' => '',
'hidelabelinorder' => '',
'hidevalueinorder' => '',
'element' =>
array (
'type' => 'radio',
'rules_type' =>
array (
'Reprint_0' =>
array (
0 => '',
),
'Edit Artwork_1' =>
array (
0 => '',
),
),
'_' =>
array (
'price_type' => '',
),
),
'name' => '',
'value' => 'Edit Artwork',
'price' => '',
'section' => '58073632e582b5.35893028',
'section_label' => '',
'percentcurrenttotal' => 0,
'currencies' =>
array (
),
'price_per_currency' =>
array (
'GBP' => '',
),
'quantity' => 1,
'multiple' => '1',
'key' => 'Edit Artwork_1',
'use_images' => '',
'changes_product_image' => '',
'imagesp' => '',
'images' => '',
),
1 =>
array (
'mode' => 'builder',
'cssclass' => '',
'hidelabelinorder' => '',
'hidevalueinorder' => '',
'element' =>
array (
'type' => 'radio',
'rules_type' =>
array (
'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG_0' =>
array (
0 => '',
),
'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-21.JPG_1' =>
array (
0 => '',
),
'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-77.JPG_2' =>
array (
0 => '',
),
),
'_' =>
array (
'price_type' => '',
),
),
'name' => 'Main Image Replacement',
'value' => 'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG',
'price' => '',
'section' => '58073632e582d2.46631826',
'section_label' => 'Main Image Replacement',
'percentcurrenttotal' => 0,
'currencies' =>
array (
),
'price_per_currency' =>
array (
'GBP' => '',
),
'quantity' => 1,
'multiple' => '1',
'key' => 'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG_0',
'use_images' => 'images',
'changes_product_image' => '',
'imagesp' => '',
'images' => 'http://burhill.immaculate.co.uk/wp-content/uploads/2016/10/BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14-150x150.jpg',
),
2 =>
array (
'mode' => 'builder',
'cssclass' => 'col-6',
'hidelabelinorder' => '',
'hidevalueinorder' => '',
'element' =>
array (
'type' => 'textfield',
'rules_type' =>
array (
0 =>
array (
0 => '',
),
),
'_' =>
array (
'price_type' => '',
),
),
'name' => 'Complimentary',
'value' => 'Comp Text',
'price' => '',
'section' => '58073632e582f4.32183997',
'section_label' => 'Complimentary',
'percentcurrenttotal' => 0,
'currencies' =>
array (
),
'price_per_currency' =>
array (
),
'quantity' => 1,
),
3 =>
array (
'mode' => 'builder',
'cssclass' => 'col-6',
'hidelabelinorder' => '',
'hidevalueinorder' => '',
'element' =>
array (
'type' => 'textfield',
'rules_type' =>
array (
0 =>
array (
0 => '',
),
),
'_' =>
array (
'price_type' => '',
),
),
'name' => 'Quote Code',
'value' => 'Code Text',
'price' => '',
'section' => '58073632e58317.46363272',
'section_label' => 'Quote Code',
'percentcurrenttotal' => 0,
'currencies' =>
array (
),
'price_per_currency' =>
array (
),
'quantity' => 1,
),
)
foreach($your_array as $key => $value) {
$your_value = $value['value'];
$your_label = $value['section_label'];
}
This should work for you as long as i got the right keys there.
ref: https://stackoverflow.com/a/25730860/2735734
How to Tell PayPal to automatically process the monthly payment?
UPDATE 1
here is the PayPal Reponses:
CreateAgreement result:
array (
'name' => 'my name',
'description' => 'my description',
'plan' =>
array (
'id' => 'P-95307423V8719480UI4T4SGG',
'state' => 'ACTIVE',
'name' => 'title here',
'description' => 'description here',
'type' => 'INFINITE',
'payment_definitions' =>
array (
0 =>
array (
'id' => 'PD-140035022V340531AI4T4SGG',
'name' => 'Regular Payments',
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.5',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'id' => 'CHM-9G272533RU378412KI4T4SGG',
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0',
),
'max_fail_attempts' => '0',
'return_url' => 'http://example.com/ok',
'cancel_url' => 'http://example.com/cancel',
'auto_bill_amount' => 'YES',
'initial_fail_amount_action' => 'CONTINUE',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4N736816FP8632455',
'rel' => 'approval_url',
'method' => 'REDIRECT',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-4N736816FP8632455/agreement-execute',
'rel' => 'execute',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T11:54:20-00:00',
)
AND after the client approved.
ExecuteAgreement result:
array (
'id' => 'I-CD3VD66KJKXX',
'state' => 'Active',
'description' => 'my description',
'plan' =>
array (
'payment_definitions' =>
array (
0 =>
array (
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.50',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1.00',
),
),
1 =>
array (
'type' => 'SHIPPING',
'amount' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'max_fail_attempts' => '0',
'auto_bill_amount' => 'YES',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/suspend',
'rel' => 'suspend',
'method' => 'POST',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/re-activate',
'rel' => 're_activate',
'method' => 'POST',
),
2 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/cancel',
'rel' => 'cancel',
'method' => 'POST',
),
3 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/bill-balance',
'rel' => 'self',
'method' => 'POST',
),
4 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/set-balance',
'rel' => 'self',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T07:00:00Z',
'agreement_details' =>
array (
'outstanding_balance' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'cycles_remaining' => '0',
'cycles_completed' => '0',
'next_billing_date' => '2014-10-25T10:00:00Z',
'final_payment_date' => '1970-01-01T00:00:00Z',
'failed_payment_count' => '0',
),
)
note the start_date for the first reponse to the second...
The first payement isn't made... (And I don't know for the other, I've try today with a daily payement... I have to wait now...)
In the Pre-Approved area on the Sandbox Account, is in Active and inform about next billing correctly.
Once the user completes and submits subscription purchase page you have created, the subscription will begin and will automatically rebill the customer's account on whatever interval you have selected. You do not have to do anything.
Updated: The REST API also automatically processes subscriptions. You do not have to resubmit monthly. The PayPal sandbox was updated in July of this year to enable you to test and process subscriptions. There are no issues being reported in the dev community about this not working, so I suspect it is something on your side.
If you haven't already. please review this:
https://developer.paypal.com/docs/integration/direct/test-the-api/
There are billing plan and billing subscription sections. If you still have a problem, post your billing plan code and the response you are receiving.
How can i create one-to-many relationship with my custom module. And add subpanel to Campaign module
Campaign vardefs
$dictionary["Campaign"]["fields"]["costs"] =
array (
'name' => 'costs',
'type' => 'link',
'relationship' => 'campaign_costs',
'module'=>'Costs',
'bean_name'=>'Costs',
'source'=>'non-db',
'vname'=>'LBL_AUCTIONS',
);
$dictionary['Campaign']['relationships']['campaign_costs'] =
array (
'lhs_module'=> 'Campaigns',
'lhs_table'=> 'campaigns',
'lhs_key' => 'id',
'rhs_module'=> 'Costs',
'rhs_table'=> 'cots',
'rhs_key' => 'campaign_id',
'relationship_type'=>'one-to-many'
);
layout_defs properties
$layout_defs["Campaigns"]["subpanel_setup"]["campaign_costs"] = array (
'order' => 2,
'module' => 'Costs',
'subpanel_name' => 'default',
'sort_order' => 'desc',
'sort_by' => 'date_entered',
'title_key' => 'LBL_SUBPANEL_COSTS',
'get_subpanel_data' => 'costs', //имя поля link
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
Custom module vardefs
$dictionary['Costs']['fields']['campaign_id'] =
array (
'required' => false,
'name' => 'campaign_id',
'vname' => '',
'type' => 'id',
'massupdate' => 0,
'importable' => 'true',
'audited' => 0,
'len' => 36,
);
$dictionary['Costs']['fields']['campaign_name'] =
array (
'required' => false,
'source' => 'non-db',
'name' => 'campaign_name',
'vname' => 'LBL_CAMPAIGN_NAME',
'type' => 'relate',
'massupdate' => 0,
'comments' => '',
'help' => '',
'audited' => 1,
'len' => '100',
'id_name' => 'campaign_id',
'ext2' => 'Campaigns',
'module' => 'Campaigns',
'rname' => 'name',
'studio' => 'visible',
);
The relationship is added, but subpanel doesn't appear at campaigns module.
In your $dictionary["Campaign"]["fields"]["costs"], change bean_name from Costs to Cost.
I take it you have enabled the subpanel in the admin-menu? (index.php?module=Administration&action=ConfigureTabs)
Does your error-logs say anything?