{"id":175,"date":"2019-09-02T05:19:33","date_gmt":"2019-09-02T05:19:33","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/vuely\/?page_id=175"},"modified":"2019-10-19T07:02:02","modified_gmt":"2019-10-19T07:02:02","slug":"adding-new-component","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/vuely\/adding-new-component\/","title":{"rendered":"Adding New Component"},"content":{"rendered":"\n<p>We will help you in creating a new component. Follow the steps below to add a new component(example: test component):<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Create a new folder in <code>src-&gt;views<\/code> . Ex: As we have created a test folder inside <code>src-&gt;views<\/code> folder.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" width=\"308\" height=\"92\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/folder-struct1.png\" alt=\"\" class=\"wp-image-176\" srcset=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/folder-struct1.png 308w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/folder-struct1-300x90.png 300w\" sizes=\"(max-width: 308px) 100vw, 308px\" \/><figcaption>Test Folder Created<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Step 2: <\/strong>In test folder, create a file named with the FolderName.vue. Ex: test.vue.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" width=\"146\" height=\"98\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/test-file.png\" alt=\"\" class=\"wp-image-177\"\/><figcaption>Created Vue File<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Step 3: <\/strong>Place the given code inside the file you have created in the above step. Ex: In test.vue file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;template&gt;<br>  &lt;div&gt;<br>    &lt;page-title-bar&gt;&lt;\/page-title-bar&gt;<br>    &lt;h1&gt;Test is Working&lt;\/h1&gt;<br>  &lt;\/div&gt;<br>&lt;\/template&gt;<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>We have to link the newly created component in the menu. Go to <code>src-&gt;store-&gt;modules-&gt;sidebar-&gt;data.js<\/code> file. When you open the file, you will see the code structure like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Sidebar Routers<br> export const menus = {<br>     'message.general': [<br>         {<br>             action: 'zmdi-view-dashboard',<br>             title: 'message.dashboard',<br>             active: true,<br>             items: [<br>                 { title: 'message.ecommerce', path: '\/default\/dashboard\/ecommerce', exact: true },<br>                 { title: 'message.webAnalytics', path: '\/mini\/dashboard\/web-analytics', exact: true },<br>                 { title: 'message.magazine', path: '\/horizontal\/dashboard\/magazine', exact: true },<br>                 { title: 'message.news', path: '\/boxed-v2\/dashboard\/news', exact: true },<br>                 { title: 'message.agency', path: '\/boxed\/dashboard\/agency', exact: true },<br>                 { title: 'message.saas', path: '\/horizontal\/dashboard\/saas', exact: true }<br>             ]<br>         }<br>     ]<br>     \u2026<br> }<\/pre>\n\n\n\n<p>Add the link for newly created component in the menus object. Now your file will looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Sidebar Routers<br> export const menus = {<br>     'message.general': [<br>         {<br>             action: 'zmdi-view-dashboard',<br>             title: 'message.dashboard',<br>             active: true,<br>             items: [<br>                 { title: 'message.ecommerce', path: '\/default\/dashboard\/ecommerce', exact: true },<br>                 { title: 'message.webAnalytics', path: '\/mini\/dashboard\/web-analytics', exact: true },<br>                 { title: 'message.magazine', path: '\/horizontal\/dashboard\/magazine', exact: true },<br>                 { title: 'message.news', path: '\/boxed-v2\/dashboard\/news', exact: true },<br>                 { title: 'message.agency', path: '\/boxed\/dashboard\/agency', exact: true },<br>                 { title: 'message.saas', path: '\/horizontal\/dashboard\/saas', exact: true }<br>             ]<br>         }<br>     ],<br>     \/\/ This is the new object you have to create for your new component.<br>     'message.testpages': [<br>         {<br>             action: 'zmdi-view-dashboard',<br>             title: 'message.test',<br>             active: false,<br>             items: [<br>                 { title: 'message.test', path: '\/test'},<br>             ]<br>         }<br>     ]<br> }<\/pre>\n\n\n\n<p>The description of the keys used in the code are:<\/p>\n\n\n\n<ol><li>action is icon<\/li><li>title is page title<\/li><li>active is state(true in dashboard case only, false in this case)<\/li><li>items is an array of sub menu(if there is no sub menu then set it to null)<\/li><\/ol>\n\n\n\n<h6>There are few things you need to take care about:<\/h6>\n\n\n\n<ol><li>State is always set to false in new components, It is true in dashboard case only.<\/li><li>If there exists some sub menu items then pass it in the form of array to items. Make Sure the items of new component only contains title &amp; path, not the exact key.<\/li><li>If there is no sub menu, then the value of items key is set to null <code>items: null<\/code>.<\/li><li>If items is null then you have to pass the path in the main object like below: <pre> { \n     action: 'zmdi-view-dashboard', \n     title: 'message.test', \n     active: false, \n     items: null, \n     path: '\/test', \n} <\/pre><\/li><\/ol>\n\n\n\n<p><strong>Step 5: <\/strong>Add the route for the newly created component. Follow the given instructions to add the route. Open the <code>src-&gt;router-&gt;default.js<\/code> file. Import the test component like below to use it in the rest of the file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const test = () =&gt; import('Views\/test\/test');<\/pre>\n\n\n\n<p>Now add the component in the children array:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export default {<br>   path: '\/',<br>   component: Full,<br>   redirect: '\/default\/dashboard\/ecommerce',<br>   children: [<br>      ...<br>      {<br>         component: test,<br>         path: '\/default\/test',<br>         meta: {<br>            requiresAuth: true,<br>            title: 'message.test',<br>            breadcrumb: 'Test'<br>         }<br>      }<br>   ]<br>}<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote blockquote-warning\"><p>If you choose a different layout for your template, then you have to follow the above mentioned step for that particular layout also. Make sure to add the path accordingly.<\/p><\/blockquote>\n\n\n\n<p>Now save the file and open the browser, you will see your added component in the template like below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"701\" height=\"567\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/addedcompo.png\" alt=\"\" class=\"wp-image-190\" srcset=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/addedcompo.png 701w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/addedcompo-300x243.png 300w\" sizes=\"(max-width: 701px) 100vw, 701px\" \/><figcaption>Added Component<\/figcaption><\/figure>\n\n\n\n<p>Don&#8217;t panic about the strings like message.testpages or message.test. We need to create these strings in the <code>index.js<\/code> file in the <code>src-&gt;lang-&gt;en<\/code> folder like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export default {<br>  -------<br>  -------<br>  test: \"Test\",<br>  testpages:\"My Page\"<br>}<\/pre>\n\n\n\n<p>Save this file and open the browser, your strings would be replaced by the message you have provided in the <code>index.js<\/code> file.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote blockquote-warning\"><p>Make sure if you are using any other language in the template then you will define the strings in that language folder also.<\/p><\/blockquote>\n\n\n\n<p>Now, You have successfully created a new component(named: test) in the template.<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"175\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">2    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"175\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>We will help you in creating a new component. Follow the steps below to add a new component(example: test component): Step 1: Create a new folder in src-&gt;views . Ex: As we have created a test folder inside src-&gt;views folder. Step 2: In test folder, create a file named with the FolderName.vue. Ex: test.vue. Step [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/175"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":10,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/175\/revisions"}],"predecessor-version":[{"id":710,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/175\/revisions\/710"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/media?parent=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}