Powered by Blogger.
advertisement

Tuesday 3 May 2016

How to remove the views menu from Blogger Dynamic Views

Advertisement
advertisement

As a follow up on my first article on Dynamic Views,  ............ here's a quick trick to remove the "views" menu in the menu bar.

Typically at the top of all Dynamic Views templates, you'll see a menu to select views other than the one you selected for your blog. It looks something like:


But what it you would prefer not to have this menu, then go to the template editor and change the view loading code from

<script language='javascript' type='text/javascript'>
  window.onload = function() {
    blogger.ui().configure().view();
  };
</script>

to

<script language='javascript' type='text/javascript'>
  window.onload = function() {
    blogger.templates().compile(
        blogger.templates().template("Header").raw()
            .replace(/{block:HasViews[\s\S]*block:HasViews}/,""));
    blogger.ui().configure().view();
  };
</script>

This will remove the section of the Header conditioned on having views {block:HasViews}...{/block:HasViews} that renders the menu for the views.

The new view looks like:

Advertisement
advertisement