Empty head tag when applying View to whole page

Support MB Views Empty head tag when applying View to whole pageResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24057
    Beda SchmidBeda Schmid
    Participant

    When I apply a view to The whole page layout, including header and footer, then the source code in the front end becomes:

    
    <html>
    <head></head>
      <body>
        Header View made with Metabox (included with ShortCode inside Body View)
        Body made with Metabox (applied to The whole page layout, including header and footer)
        Footer on posts made by Metabox (included with ShortCode inside Body View)
      </body>
    </html>
    

    I tried this with several themes, and always the the same result.
    Shouldn't the head tag be left alone and to be output by the theme?
    Ideally, "The whole page layout, including header and footer", means the header.php and footer.php but not the head tag, which is not related to display, but functionality.

    In any case - how'd you suggest to put back all required head contents when using MetaBox Views?
    Usually, we would want a head like so:

    
    <head>
        <meta charset="<?php bloginfo( 'charset' ); ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <link rel="profile" href="http://gmpg.org/xfn/11">
    <?php wp_head(); ?>
    </head>
    

    (or similar)

    Note:
    My goal is to design a whole template, inclusive menu and footer, with MB Views.
    Perhaps I am approaching this wrongly...

    #24062
    Long NguyenLong Nguyen
    Moderator

    Hi,

    There are three options to render the view:

    • The whole page layout, including header and footer: that means all sections header, main content, footer will be replaced by the view content.
    • The layout between header and footer: that means the section main content (post content and sidebar) between the header and footer will be replaced by the view content.
    • Only the post content area: that means only the post content will be replaced by the view content, keep the section sidebar.

    See my screenshot to get more details https://share.getcloudapp.com/qGuleZzO.

    #24064
    Beda SchmidBeda Schmid
    Participant

    Hello
    Yes, I know that.

    But when you choose The whole page layout, including header and footer, then the result is a empty head tag, such as I explain in my firs post.

    The result will be (in HTML source):
    <html>
    <head></head>
    <body>
    HERE WILL DISPLAY THE VIEW ASSIGNED TO The whole page layout, including header and footer
    </body>
    </html>

    As you can see head is empty
    This is not good, as head should not be empty, or at least not insert by the plugin, so we could populate it on our own.
    Note, this head tag is not coming from theme, it comes form View assigned to the page.

    Thanks!

    #24067
    Long NguyenLong Nguyen
    Moderator

    Hi,

    To include the header in the view, you can just use the WP function get_header()

    {{ mb.get_header() }}
    HERE WILL DISPLAY THE VIEW

    see more on this documentation https://developer.wordpress.org/themes/basics/template-files/#using-template-files.

    or add the <head> tag to show only the <head>

    <head>
    <meta charset="{{mb.bloginfo( 'charset' )}}">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="profile" href="http://gmpg.org/xfn/11">
    {{ mb.wp_head() }}
    </head>
    <body>
        HERE WILL DISPLAY THE VIEW
    </body>
    #24071
    Beda SchmidBeda Schmid
    Participant

    Hummmm...

    Ok, here is what I found:

    1. If we just create a view and assign to The whole page layout, including header and footer, but do NOT insert a head tag, or do NOT call get_header, then the HTML source will be

      <html><head></head><body>This would be the View content. Whatever we put here, code, HTML, Twig, etc etc.</body></html>
    2. If we insert manually a head tag, it will replace the empty head tag, and produce what we insert in the View

    3. If we call get_header, it also replaces the head tag, and puts in what comes from the theme

    So far, so good, I misunderstood how it works, I think.
    I thought the view would simply replace all content and not expect any head or else like a "completely blank output"

    I can proceed, it is clear now.

    Thanks a lot, Long!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.