Referensi Kode Snippet Blogger


Berikut dokumentasi kode snippet Blogger Terbaru beserta penjelasan dan contoh penulisannya.



  1. Gadget Blog V2 (Widget Blog Post)

    Penggunaan snippet di dalam tag b:loop postingan:

    <b:loop values='data:posts' var='post'>
      ...
    </b:loop>
    1. Date

      Menampilkan Tanggal di Postingan

      data:posts[i].date
      Format penulisan Published (terpublikasi)
      <!-- Date (published) -->
      <time expr:datetime='data:post.date.iso8601' expr:title='data:post.date.iso8601'>
        <data:post.date/>
      </time>
      Dengan Kustomisasi
      <!-- Date (published) -->
      <time expr:datetime='data:post.date.iso8601' expr:title='data:post.date.iso8601'>
        <b:eval expr='format(data:post.date, "dd/MM/YYYY")'/>
      </time>
      Format penulisan Last Updated (terpublikasi)
      <!-- Date (updated) -->
      <time expr:datetime='data:post.lastUpdated.iso8601' expr:title='data:post.lastUpdated.iso8601'>
        <data:post.lastUpdated/>
      </time>
      Dengan Kustomisasi
      <!-- Date (updated) -->
      <time expr:datetime='data:post.lastUpdated.iso8601' expr:title='data:post.lastUpdated.iso8601'>
        <b:eval expr='format(data:post.lastUpdated, "dd/MM/YYYY")'/>
      </time>
      Tabel Parameter Kustomisasi
      PeriodSymbolExample outputDescription
      TahunYY17Tahun, 2 digit
      YYYY2017Tahun, 4 digit
      BulanM1, 11Bulan, minimum 1 digit
      MM01, 11Bulan, 2 digit
      MMMJan, NovBulan, 3 karakter
      MMMMJanuary, NovemberBulan, nama panjang
      MMMMMJ, NBulan, karakter pertama
      Pekanw1, 11Pekan dalam Tahun, minimum 1 digit
      ww01, 11Pekan dalam Tahun, 2 digit
      W4Pekan dalam Bulan, 1 digit
      Hari / Tanggald1, 11Tanggal dalam Bulan, minimum 1 digit
      dd01, 11Tanggal dalam Bulan, 2 digit
      D1, 55, 362Tanggal dalam Tahun, minimum 1 digit
      DD01, 55, 362Tanggal dalam Tahun, minimum 2 digit
      DDD001, 055, 362Tanggal dalam Tahun, minimum 3 digit
      F3Hari ke-X dari Bulan. Contoh; Selasa ke-3 dari Bulan.
      EM, TNama hari dari Pekan. 1 karakter
      EEMo, TuNama hari dari Pekan. 2 karakter
      EEEMon, TueNama hari dari Pekan. 3 karakter
      EEEEMonday, TuesdayNama panjang hari dari Pekan.
      Waktu dalam HariaaaaAM, PMNamanya mungkin berbeda tergantung regional.
      bbbbMorning, Afternoon, Evening
      BBBB
      Jamh1, 11Jam [1-12], minimum 1 digit
      hh01, 11Jam [1-12], 2 digit
      H1, 21Jam [0-23], minimum 1 digit
      HH01, 21Jam [0-23], 2 digit
      Menitm1, 59Menit, minimum 1 digit
      mm01, 59Menit, 2 digit
    2. Labels

      Label yang ada pada postingan.

      data:posts[i].labels
      Opsi Label

      12: adalah jumlah maksimum Label yang dapat ditampilkan pada suatu laman.

      Default
      <!-- Labels -->
      <b:if cond='data:post.labels'>
        <b:loop index='i' values='data:post.labels' var='label'>
          <a expr:href='params(data:label.url, { max-results: "12" })' expr:title='data:label.name'>
            <b:attr name='b:whitespace' value='remove'/>
            <data:label.name/>
          </a>
        </b:loop>
      </b:if>
      Default dengan Fallback
      <!-- Labels -->
      <b:if cond='data:post.labels'>
        <b:loop index='i' values='data:post.labels' var='label'>
          <a expr:href='params(data:label.url, { max-results: "12" })' expr:title='data:label.name'>
            <b:attr name='b:whitespace' value='remove'/>
            <data:label.name/>
          </a>
        </b:loop>
      <b:else/><!-- fallback -->
        <span>Unlabelled</span>
      </b:if>
      Pembatas Koma
      <!-- Labels -->
      <b:if cond='data:post.labels'>
        <b:loop index='i' values='data:post.labels' var='label'>
          <a expr:href='params(data:label.url, { max-results: "12" })' expr:title='data:label.name'>
            <b:attr name='b:whitespace' value='remove'/>
            <data:label.name/>
          </a><b:if cond='data:i != (data:post.labels.size - 1)'>,</b:if>
        </b:loop>
      </b:if>
      Pembatas Koma dengan Fallback
      <!-- Labels -->
      <b:if cond='data:post.labels'>
        <b:loop index='i' values='data:post.labels' var='label'>
          <a expr:href='params(data:label.url, { max-results: "12" })' expr:title='data:label.name'>
            <b:attr name='b:whitespace' value='remove'/>
            <data:label.name/>
          </a><b:if cond='data:i != (data:post.labels.size - 1)'>,</b:if>
        </b:loop>
      <b:else/><!-- fallback -->
        <span>Unlabelled</span>
      </b:if>
  2. Page Types (Conditional Tags)

    Tag kondisional pada berbagai macam tipe laman, yang memungkinkan untuk menentukan bagian dari kode template pada suatu tipe laman yang spesifik atau URL tertentu.

    1. Basic

      Homepage
      <b:if cond='data:view.isHomepage'>
        <!-- https://example.blogspot.com -->
      </b:if>
      Single Page
      <b:if cond='data:view.isPost'>
        <!-- https://example.blogspot.com/<year>/<month>/<permalink>.html -->
      </b:if>
      Static Page
      <b:if cond='data:view.isPage'>
        <!-- https://example.blogspot.com/p/<permalink>.html -->
      </b:if>
      Search (Label) Page
      <b:if cond='data:view.search.label'>
        <!-- 1. https://example.blogspot.com/search/label/<label-name> -->
        <!-- 2. https://example.blogspot.com/search?label=<label-name> -->
      </b:if>
      Search (Query) Page
      <b:if cond='data:view.search.query'>
        <!-- https://example.blogspot.com/search?q=<query> -->
      </b:if>
      Search (Default) Page
      <b:if cond='data:view.search and !data:view.search.label and !data:view.search.query'>
        <!-- https://example.blogspot.com/search -->
      </b:if>
      Archive Page
      <b:if cond='data:view.isArchive'>
        <!-- 1. https://example.blogspot.com/<year> -->
        <!-- 2. https://example.blogspot.com/<year>/<month> -->
        <!-- 3. https://example.blogspot.com/<year>_<month>_<day>_archive.html -->
      </b:if>
      Error Page
      <b:if cond='data:view.isError'>
        <!-- https://example.blogspot.com/<404> -->
      </b:if>
    2. Laman Khusus

      Layout Mode
      <b:if cond='data:view.isLayoutMode'>
        <!-- https://www.blogger.com/blogger.g?blogID=<blogID>#pageelements -->
      </b:if>
      Preview Page
      <b:if cond='data:view.isPreview'>
        <!-- Preview page -->
      </b:if>
    3. URL Tertentu

      Single Page Tertentu
      <b:if cond='data:view.url == "https://example.blogspot.com/1945/08/wow.html"'>
        <!-- https://example.blogspot.com/1945/08/wow.html -->
      </b:if>
      Static Page Tertentu
      <b:if cond='data:view.url == "https://example.blogspot.com/p/wow.html"'>
        <!-- https://example.blogspot.com/p/wow.html -->
      </b:if>
      Search (Label) Page Tertentu
      <b:if cond='data:view.search.label == "WOW"'>
        <!-- 1. https://example.blogspot.com/search/label/WOW -->
        <!-- 2. https://example.blogspot.com/search?label=WOW -->
      </b:if>
      Search (Query) Page Tertentu
      <b:if cond='data:view.search.query == "wow"'>
        <!-- https://example.blogspot.com/search?q=wow -->
      </b:if>
    4. Ringkasan

      ExpressionTipe DataKeterangan
      data:view.archive.daynumberDay of the current archive page. e.g. 17.
      data:view.archive.monthnumberThe month of the current archive page. e.g. 8
      data:view.archive.yearnumberYear of the current archive page. e.g. 1945
      data:view.descriptionstringDescription of the current pageview.
      data:view.featuredImageimageFeatured image for the current page or post.
      data:view.isArchivebooleanIndicating Archive feed.
      data:view.isErrorbooleanThe current view is 404 or error page.
      data:view.isHomepagebooleanThe current view is Homepage.
      data:view.isLabelSearchbooleanThe current view is the Label page.
      data:view.isMultipleItemsbooleanA page view is contained multiple posts, eg, Search, Label, Homepage, etc.
      data:view.isMobilebooleanA pageview has parameter m=1.
      data:view.isPagebooleanis Showing a Blog Static Page.
      data:view.isPostbooleanis Showing a Single Post.
      data:view.isPreviewbooleanIn preview mode.
      data:view.isSearchbooleanAll page contain word 'search' in the URL.
      data:view.isSingleItembooleanis a Single item, wether is the single post or static page.
      data:view.pageIdnumberThe id of the static page.
      data:view.postIdnumberThe id of the post.
      data:view.search.labelstringUsed for filtering label of the current view.
      data:view.search.querystringUsed for filtering search keyword.
      data:view.search.resultsMessagestringThe message about the search results being shown.
      data:view.search.resultsMessageHtmlstringA message about the result with HTML Link.
      data:view.titlestringTitle of the current view.
      data:view.urlurlThe URL of the current view.
    5. Contoh Penggunaan

      Sintaks dan Atributnya
      <b:if cond='EXPRESSION'>
       <!-- executed if a specified condition is true -->
      <b:elseif cond='EXPRESSION2'/>
       <!-- executed if upper condition test is false  -->
      <b:else/>
       <!-- executed if all condition is false -->
      </b:if>
      Contoh Tag Kondisional
      Dengan Blogger Data Expression
      <b:if cond='data:view.isHomepage'>
       <!-- Execute -->
      </b:if>
      Dengan Data Boolean
      <b:if cond='data:blog.pageTitle'>
       <b:if cond='false'>
        <!-- Execute -->
       </b:if>
      </b:if>
      Dengan Operator Komparasi
      <b:if cond='data:blog.isMobile == "true"'>
       <!-- Execute -->
      </b:if>
      Dengan Operator Membership
      <b:if cond='!data:view.isMobile and data:view.isHomepage or data:view.isSearch'>
       <!-- Execute -->
      </b:if>
      Dengan Operator Lambda
      <b:if cond='data:view.search.label in ["Foo", "Bar", "Baz"]'>
       <!-- span Block 1 -->
      <b:elseif cond='data:view.search.label not in ["Baz", "Qux"]'/>
       <!-- span Block 2 --> 
      <b:else/>
       
      </b:if>



Reference:
[1] https://wrapblogger.github.io/blogger/snippets/
[2] https://bloggerbook.blakbin.com/2018/11/blogger-cheatsheet-dataview.html
[3] https://bloggerbook.blakbin.com/2018/11/blogger-bif-belse-and-belseif-tag.html
[4] https://support.google.com/blogger/answer/47270?hl=en
[5] https://bloggercode-blogconnexion.blogspot.com/