{"id":11488,"date":"2020-03-02T10:06:16","date_gmt":"2020-03-02T10:06:16","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=11488"},"modified":"2021-11-12T06:43:59","modified_gmt":"2021-11-12T06:43:59","slug":"how-to-include-sub-views-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-include-sub-views-in-laravel\/","title":{"rendered":"How to include sub-views in Laravel."},"content":{"rendered":"\n<p>First of all, we make a new directory in the view folder in which our subviews files are stored. To make subviews we use below function. <\/p>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">@include(address_of_subviews_file)<\/h2>\n\n\n\n<p>See below how I&#8217;m dividing my <strong>menu<\/strong> to subviews.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"625\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Sub-views1.png\" alt=\"\" class=\"wp-image-11502\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Sub-views1.png 960w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Sub-views1-300x195.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Sub-views1-768x500.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p>I am dividing my <strong>menu<\/strong> file to subview because my menu file contains multiple sections and there are multiple lines of code and I want to separate my page into subviews. For that, I separate each section into subviews. See below how:- <\/p>\n\n\n\n<p>At first, I make my <strong>team<\/strong> section into subview. So that I make a separate view file and paste the code of the <strong>team <\/strong>section into it.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"197\" height=\"77\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Sub-views2-1.png\" alt=\"\" class=\"wp-image-11511\"\/><\/figure><\/div>\n\n\n\n<p>As you see in the above image, I have moved the code into a new file and called it with the help of <strong>@include()<\/strong>. Here, <strong>subviews<\/strong> is directory name and <strong>subteam<\/strong> is file name in which I moved the code.<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">That&#8217;s all. I have included my section into subviews.<\/h3>\n\n\n\n<p>To add a variable in subviews use the below code:- <\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">@include(&#8220;subviews.subteam&#8221;,[&#8220;datas&#8221;=&gt;$name])<\/h3>\n\n\n\n<p>where, $name = variable.<br>              <\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_88389\"><iframe loading=\"lazy\"  id=\"_ytid_52496\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_88389\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First of all, we make a new directory in the view folder in which our subviews files are stored. To make subviews we use below function. @include(address_of_subviews_file) See below how&#8230; <\/p>\n","protected":false},"author":19,"featured_media":11529,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[5203],"class_list":["post-11488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=11488"}],"version-history":[{"count":30,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11488\/revisions"}],"predecessor-version":[{"id":24901,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11488\/revisions\/24901"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/11529"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=11488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=11488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=11488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}