0

I am wondering if we are able to use tiles of the promoted links to hide certain web parts of the same page. For example, when they click on a tile, one web part will be hidden on the same page. Is that possible?

0

Hiding parts of the page can be done - especially if you are using web parts that should be displayed/hidden.

Create a page with one or more web parts on it. Press F12 in Internet Explorer to start developer tools. Use "DOM Explorer" and activate DOM highlighting and select one of your web parts to toggle. You can see the element ID in source code - for example something like 'MSOZoneCell_WebPartWPQ4'.

So now assuming you want to have this hidden when entering the page and have a button to activate and again hide it - create a text file in text editor.

Copy the following into the text file and save it. Please do not forget to replace the id of your element!

<script type="text/javascript" language="JavaScript">
<!--
var i = 0;
function toggle(a)
{
var e = document.getElementById(a);


// element exists
if(!e)return true;

  // switch
  if(e.style.display=="none")
  {
  e.style.display="block"
  }
  else
  {
  e.style.display="none"
  }



return true;
}

function test()
{

var x = document.getElementById('MSOZoneCell_WebPartWPQ4');

x.style.display ="none"

}
test();



</script>

<style type="text/css">
<!--


#MSOZoneCell_WebPartWPQ4{display:none;}

-->
</style>


<a href="#" onclick="return toggle('MSOZoneCell_WebPartWPQ4')">click here to toggle the webpart</a>

Now upload this textfile to SharePoint - maybe SiteAssets. Copy the hyperlink to this file, edit the page you want to toggle contents, add a CEWP (content editor web part), edit the web part and in web part properties add the hyperlink to the text file. After saving you will see your web part is hidden and a text "click here to toggle the web part" gives you the option to have it shown and hidden again.

You can modify this script to multiple web parts and to look more nice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.