Question

I'm building an interface that allows for users to customize the webpart zones on their page to a layout of their choosing.

It seems the best way to do this is to have all possible layouts present on the page, and only render the layout that the user chooses, therefore allowing them to personalize the layout they like. ( *Meaning dynamically created web parts that are rendered at Page_init, while possible would likely not be able to hold personal state for each user* )

The issue I'm running into, is that I want to read from a configurtion list at page_load, and dynamically remove elements. I need to do this, because the layouts reside in a Jquery powered interface that relies on element.count to handle a unique type of horizontal pagination.

So, for example:

//{content} = WebPartZones
<div id="container">
  <div class="Grid" class="Home">{content}</div>
  <div class="Grid" id="GridOne" runat="server">{content}</div> <small Zone>
  <div class="Grid" id="GridTwo" runat="server">{content}</div> <large Zone>
  <div class="Grid" id="GridThree" runat="server">{content}</div> <small Zone>
  <div class="Grid" id="GridFour" runat="server">{content}</div> <large Zone>
</div>

//Home screen, plus two more panels of large webpart zones
User.Configuration.Layout = "Enum.StyleOne";
Page.GridOne.delete();
Page.GridThree.delete();

Here's where the problem comes in. I can't have the container and following elements inside of a visual web part embedded in the page, because the zones will be added to the page after init, which is not allowed and throws an exception.

I cannot use an application page, because I want this content to exist on the home page of a subsite (this page is part of a Site Definition).

I am therefore in a pickle because I want to re-arrange the content server side, but it seems to be impossible. The only thing I can think of is to embed a web part in the top of the page that renders a javascript element like window.pagelayout = StyleOne, and then have JQuery remove the elements before the PlugIn fires and reads container.elements.count.

Is there a way to do this server side? I'm worried about flicker.

Was it helpful?

Solution

Hi achieved this 100% dynamic page by creating calling content of web parts in a handler and having a controller web part that return the results in Jquery.

This method is no good for objects to do with security but it allows you to have the page load much quicker visually than it might perhaps normally would as well.

You could go into programatically moving web parts in zones but this is for everyone, and I presume this is a per user thing?

If it is, then a controller web part that is per user that uses jquery to call a handler code that returns the html content would be the slickest way of doing it in my book.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top