{"id":484,"date":"2025-06-19T10:29:16","date_gmt":"2025-06-19T10:29:16","guid":{"rendered":"https:\/\/docs.quantri.online\/?docs=developer-guide\/business-management\/xay-dung-1-custom-viewdefs-trong-suitecrm"},"modified":"2025-07-07T02:37:29","modified_gmt":"2025-07-07T02:37:29","slug":"xay-dung-1-custom-viewdefs-trong-suitecrm","status":"publish","type":"docs","link":"https:\/\/docs.quantri.online\/?docs=developer-guide\/business-management\/xay-dung-1-custom-viewdefs-trong-suitecrm","title":{"rendered":"Custom viewdefs trong BM"},"content":{"rendered":"\n<p class=\"has-large-font-size wp-block-paragraph\" id=\"loi-mo-dau\"><strong>L\u1eddi m\u1edf \u0111\u1ea7u<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u1ede BM c\u0169 khi 1 module c\u00f3 nhi\u1ec1u lo\u1ea1i (vd: t\u1edd tr\u00ecnh , \u0111\u1ec1 ngh\u1ecb, &#8230;). khi mu\u1ed1n hi\u1ec3n th\u1ecb detail view, edit view c\u1ee7a t\u1eebng lo\u1ea1i, ta th\u01b0\u1eddng hay d\u00f9ng js \u0111\u1ec3 \u1ea9n hi\u1ec7n c\u00e1c tr\u01b0\u1eddng kh\u00e1c bi\u1ec7t. \u0111i\u1ec1u \u0111\u00f3 v\u1edbi l\u00e0m ph\u00ecnh code v\u00e0 kh\u00e1 kh\u00f3 \u0111\u1ec3 debug. Cho n\u00ean v\u1edbi phi\u00ean b\u1ea3n SuiteCRM m\u1edbi \u0111\u1ec1 xu\u1ea5t t\u00e1ch chi ti\u1ebft c\u00e1c loai ra t\u1eebng view ri\u00eang.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\" id=\"tao-controlle\"><strong>T\u1ea1o file controller<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">B\u01b0\u1edbc \u0111\u1ea7u ti\u00ean ta c\u1ea7n t\u1ea1o file controller.php trong \u0111\u01b0\u1eddng d\u1eabn <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00d084\" class=\"has-inline-color\">modudes\/&lt;beanName&gt;\/controller.php<\/mark><br>\u1ede file n\u00e0y ta t\u1ea1o c\u00e1c h\u00e0m b\u1eaft \u0111\u1ea7u v\u1edbi <strong>action_&lt;t\u00ean action&gt;<\/strong>. T\u00ean action n\u1eb1m \u1edf action_view_maps.php nh\u00e9. M\u1ed9t s\u1ed1 action m\u1eb7c \u0111\u1ecbnh: detailview, editview, listview<br>v\u00ed d\u1ee5:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"846\" src=\"https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image.png\" alt=\"\" class=\"wp-image-495\" srcset=\"https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image.png 850w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-300x300.png 300w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-150x150.png 150w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-768x764.png 768w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-16x16.png 16w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-50x50.png 50w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u1edf vd tr\u00ean th\u00ec m\u00ecnh s\u1ebd b\u1eaft theo $_REQUEST[&#8216;type&#8217;] \u0111\u1ec3 \u0111i\u1ec1u h\u01b0\u1edbng v\u00e0o \u0111\u00fang view v\u00e0 viewdefs m\u00ecnh c\u1ea7n, n\u00f3 s\u1ebd l\u00e0 .<strong>view.&lt;$this-&gt;view&gt;.php<\/strong> v\u00e0 <strong>&lt;$this-&gt;view&gt;viewdefs.php<\/strong> \u0111\u1ec3 ti\u1ebfp t\u1ee5c ch\u1ec9nh s\u1eeda.. L\u1ea5y vd n\u1ebfu type m\u00ecnh l\u00e0 test m\u00ecnh s\u1ebd v\u00e0o <strong>view.edit_test.php<\/strong> v\u00e0 <strong>edit_testviewdefs.php<\/strong> \u0111\u1ec3 ti\u1ebfp t\u1ee5c ch\u1ec9nh s\u1eeda.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\" id=\"tao-file-view-custom\"><strong>T\u1ea1o file view custom<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">L\u1ea5y theo v\u00ed d\u1ee5 tr\u00ean. L\u00fac n\u00e0y m\u00ecnh s\u1ebd t\u1ea1o 1 file <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-contrast-color\">view.edit_test.php<\/mark><\/strong> trong th\u01b0 m\u1ee5c <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00d084\" class=\"has-inline-color\">modules\/&lt;beanName&gt;\/views<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">T\u1ea1i file n\u00e0y ch\u00fa \u00fd 2 h\u00e0m c\u1ea7n thi\u1ebft: getMetaDataFile v\u00e0 preDisplay:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"340\" src=\"https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-1-1024x340.png\" alt=\"\" class=\"wp-image-496\" srcset=\"https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-1-1024x340.png 1024w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-1-300x100.png 300w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-1-768x255.png 768w, https:\/\/docs.quantri.online\/wp-content\/uploads\/2025\/06\/image-1.png 1400w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">H\u00e0m getMetaDataFile d\u00f9ng \u0111\u1ec3 d\u1eabn ch\u00ednh x\u00e1c m\u00ecnh t\u1edbi file metadata n\u00e0o.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Trong h\u00e0m preDisplay th\u1ef1c ch\u1ea5t t\u01b0\u01a1ng t\u1ef1 nh\u01b0 h\u00e0m c\u1ee7a Sugarview. ch\u1ec9 kh\u00e1c m\u00ecnh b\u1ed5 sung v\u00e0o file tpl \u0111\u1ec3 suite cache \u0111\u00fang file tpl. N\u1ebfu kh\u00f4ng c\u00f3 s\u1ebd suite ch\u1ec9 cache \u0111\u00fang 1 l\u1ea7n 1 lo\u1ea1i ko cache lo\u1ea1i kh\u00e1c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">P\/s: Nh\u1edb khai b\u00e1o th\u00eam \u1edf file EditViewTest.tpl \u1edf <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00d084\" class=\"has-inline-color\">modules\/&lt;beanName&gt;\/tpl<\/mark>.<br><\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\" id=\"T\u1ea1o-file-viewdefs.php\"><strong>T\u1ea1o file viewdefs.php<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cu\u1ed1i c\u00f9ng t\u1ea1o 1 file <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-contrast-color\"><strong>edit_testviewdefs.php<\/strong><\/mark><\/strong> trong th\u01b0 m\u1ee5c <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00d084\" class=\"has-inline-color\">modules\/&lt;beanName&gt;\/metadata.<\/mark><br>File n\u00e0y gi\u1ed1ng nh\u01b0 editviewdefs.php th\u00f4ng th\u01b0\u1eddng ban t\u00f9y ch\u1ec9nh theo docs SuiteCRM.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\" id=\"ket-bai\"><strong>K\u1ebft b\u00e0i<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0110\u00e2y l\u00e0 c\u00e1c b\u01b0\u1edbc c\u01a1 b\u1ea3n \u0111\u1ec3 custom ra 1 viewdefs ri\u00eang. C\u00e1c detailview v\u00e0 listview c\u0169ng t\u01b0\u01a1ng t\u1ef1. Tr\u00ean th\u1ef1c t\u1ebf n\u1ebfu nhi\u1ec1u lo\u1ea1i b\u1ea1n n\u00ean vi\u1ebft d\u1ea1ng k\u1ebf th\u1eeba \u0111\u1ec3 tr\u00e1nh l\u1eb7p qu\u00e1 nhi\u1ec1u code. Xin c\u1ea3m \u01a1n \u0111\u00e3 \u0111\u1ecdc b\u00e0i.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>L\u1eddi m\u1edf \u0111\u1ea7u \u1ede BM c\u0169 khi 1 module c\u00f3 nhi\u1ec1u lo\u1ea1i (vd: t\u1edd tr\u00ecnh , \u0111\u1ec1 ngh\u1ecb, &#8230;). khi mu\u1ed1n hi\u1ec3n th\u1ecb detail view, edit view c\u1ee7a t\u1eebng lo\u1ea1i, ta th\u01b0\u1eddng hay d\u00f9ng js \u0111\u1ec3 \u1ea9n hi\u1ec7n c\u00e1c tr\u01b0\u1eddng kh\u00e1c bi\u1ec7t. \u0111i\u1ec1u \u0111\u00f3 v\u1edbi l\u00e0m ph\u00ecnh code v\u00e0 kh\u00e1 kh\u00f3 \u0111\u1ec3 debug. Cho n\u00ean [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":281,"menu_order":6,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-484","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=484"}],"version-history":[{"count":11,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/484\/revisions"}],"predecessor-version":[{"id":506,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/484\/revisions\/506"}],"up":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/281"}],"wp:attachment":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=484"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}