Main layout.master.cs has dependencies on specific div tags.

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/15/2006 7:15:26 AM
Gravatar
Total Posts 10

Main layout.master.cs has dependencies on specific div tags.

I noticed that in the Page_Load in the layout.Master.cs there are a bunch of references to divRight, divCenter, divLeft -- that puts a dependency on knowing what the designer wants to do in their master page.

What about replacing them with "FindControl" calls?  or set the styles and visible flags on the content of the contentplaceholders?

3/15/2006 7:46:52 AM
Gravatar
Total Posts 18444

Re: Main layout.master.cs has dependencies on specific div tags.

Designers can do a lot of different things but some things have to be consistent. Those three divs in particular need to be there and certain css classes also need to exist in order to adapt the layout to 1, 2, or 3 columns at runtime depending on whether the columns have content.

Designers can of course modify the style in the classes

To achieve 3 column layout with no tables, the left and right divs are positioned absolutely and with fixed widths and the center div is programmatically assigned the css class center-rightandleftmargins which has appropriate margins to not overlap the outer columns. If there is no content in the right column then the center div is programatically assigned the css class center-leftmargin which only has margin to avoid overlap with the left column, etc.

Different pages within the site can have different column configurations because they can have different content and the layout needs to adapt accordingly. If I can't rely on those divs (Panels) being there I can't assign css classes programatically.

I don't know if the content placeholders render as divs like panels do but to me it made sense to decouple layout from the placeholders by just putting them in the div/panel containers and divs are the appropriate mechanism for layout grouping/positioning.

All decisions have tradeoffs, I have tried to make decisions that make things work easily and still allow a lot of creative freedom for designers

Things may change some when I convert everything to web parts and introduce web part zones but I think the basic concept will remain
3/15/2006 8:37:52 AM
Gravatar
Total Posts 10

Re: Main layout.master.cs has dependencies on specific div tags.

Here is what I was thinking :)  This leaves the only requirment on the designer is to include the ContentPlaceHolders.  And you could go one step further to check to see if they exist and if not, ignore them.

Add the following code to the top of layout.Master.cs (Line 28 I think)

ContentPlaceHolder cphLeft    = (ContentPlaceHolder) FindControl("leftContent");
ContentPlaceHolder cphMain    = (ContentPlaceHolder) FindControl("mainContent");
ContentPlaceHolder cphRight   = (ContentPlaceHolder) FindControl("rightContent");

Panel divLeft    = (Panel) FindControl("divLeft");
Panel divCenter  = (Panel) FindControl("divCenter");
Panel divRight   = (Panel) FindControl("divRight");

if (divLeft == null)
{
 divLeft = (Panel) cphLeft.FindControl("divLeft");
 if (divLeft == null)
 {
  divLeft        = new Panel();
  divLeft.ID    = "divLeft";
  cphLeft.Controls.AddAt(0, divLeft);
 }
}

if (divCenter == null)
{
 divCenter = (Panel) cphMain.FindControl("divCenter");
 if (divCenter == null)
 {
  divCenter        = new Panel();
  divCenter.ID    = "divCenter";
  cphMain.Controls.AddAt(0, divCenter);
 }
}

if (divRight == null)
{
 divRight = (Panel) cphRight.FindControl("divRight");
 if (divRight == null)
 {
  divRight    = new Panel();
  divRight.ID = "divRight";
  cphRight.Controls.AddAt(0, divRight);
 }
}           

3/15/2006 8:57:22 AM
Gravatar
Total Posts 18444

Re: Main layout.master.cs has dependencies on specific div tags.

I don't get it. Whats the problem with the requirement that the designer leave those panels in there?

It looks like your code is putting the divs inside the content placeholders which is backwards of what the containment relationship needs to be. Currently the content modules are loaded into the content palceholders which are inside the panels for positioning. Putting the panels inside the content placholders you would lose the layout and modules would be loaded in the palceholders beneath the panels.

In the future it is possible/likely that the content palceholders may go away and be replaced with web part zones, using the panels ensures that the layout won't be affected by that change. They will still do their layout thing whether they contain content palceholders or web part zones.

Make sense?
3/15/2006 9:01:35 AM
Gravatar
Total Posts 10

Re: Main layout.master.cs has dependencies on specific div tags.

If you look, I am added the divs to the 0 position in the content place holders, which wil guarantee that they are on the outside -- this keeps the releation ship that you are looking for.

The main purpose for doing this is simplicty :)  For the designers that is -- one less tag for them to remeber to add and maintain.  Now all they need to care about is the placeholder and the framework takes care of the rest.

When you move to zones, you can do much the same thing -- plus you have the option of changing the names or the tag type while still not impacting the desgin of any of the skins.

3/15/2006 9:23:40 AM
Gravatar
Total Posts 18444

Re: Main layout.master.cs has dependencies on specific div tags.

Are you sure about that?

cphLeft.Controls.AddAt(0, divLeft);

When I read the documentation for the Controls.AddAt method, it says the first param is the index in the controls collection. This would mean that in the above line divLeft would be placed as the first control inside the Controls collection for cphLeft making it a child control of cphLeft rather than making cphLeft a child control of divLeft as it should be.

I think it is clearer to have the panels in there, otherwise the designer might think he needs to add his own divs for layout.

If your code works as you say then it would help if the designer accidently left out the panels but it just seems like a very minor issue trying to prevent accidental errors by designers. I plan to beef up the documentation for skins and what needs to be in there and what is optional and designers should leave the required things in.
3/15/2006 9:27:40 AM
Gravatar
Total Posts 10

Re: Main layout.master.cs has dependencies on specific div tags.

You are correct in how you are reading the docs -- if you add the code and look at the resulting HTML you'll see where it places it.  It will always be "outside" of the content in the content region. And even if the designer "thinks" he needs his own div tags, he can still add them.  It is what I am doing now on a CSS based site theme that I am working on.

I am trying to get http://www.infragistics.com as a theme in your portal app.

3/15/2006 9:33:45 AM
Gravatar
Total Posts 18444

Re: Main layout.master.cs has dependencies on specific div tags.

Interesting. I'll give it try maybe tonight after work. Its counter intuitive but if you say thats what it does I believe you.

If it works for me as expected I don't see how it could hurt since it would only run that code in the case where the panels were left out so maybe I'll put it in there.

Let me know how it goes with the layout you're working on. I'd love to see it when its done if possible.

Cheers,

Joe
3/15/2006 9:44:46 AM
Gravatar
Total Posts 10

Re: Main layout.master.cs has dependencies on specific div tags.

Thanks.

Right now, I am working on "position" issues, it seems when I go into the Admin Site Settings, the "Edit Settings" panel is pushed up under the breadcrumb panel -- something to do with positioning I think.

When I get it right, I'll set it up for you to see :)

You must sign in to post in the forums. This thread is closed to new posts.