Take the 2-minute tour ×

Another question about the fantastic Christophe Humbert Easy Tabs library: Can the library be included in a page layout for a publishing site rather than in a content editor web part? This way it's automagically included in all pages based on the page layout, rather than a CEWP that has to be dropped into each page from the gallery.

I spent yesterday trying to achieve this with no luck; I dropped a reference to the JS file at the end of the closing tag in the page layout. This is after all the sections that will contain web parts. The tabs showed but they didn't work correctly; only the Expand All and Print Preview worked. The rest had no content. I tried moving the JS reference to other parts of the page layout, but none worked.

Your help is appreciated. Thanks.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The Easy Tabs script needs to know which Web Part zone the tabed interface should be applied to.

When you drop it in a CEWP, the code assumes that the tabs will be created in the current zone. It also assumes that it runs from within a Web Part (CEWP or other). Its first step is to crawl up the hierarchy to find the Web Part zone.

In order to make it work in a page layout, you would need to modify the code to explicitly point to the correct Web Part zone.

share|improve this answer
Thanks, Christophe. It took me a day just to discover that it only worked as a CEWP; it uses its current context. I only need the web parts in a specific DIV to be shown in a tabbed UI. Your code works its way up the tree through the initial DO-WHILE loop using the variables declared right before it. It stops when it hits the outer container MSO_ContentTable. Beyond that, it's a mystery to me. –  Alex C Sep 8 '11 at 14:58
Right. Instead of the do-while loop, you would need to directly point to the container. –  Christophe Sep 8 '11 at 15:55
Got it!! Commented out the do-while loop and added this: p = document.getElementById('ctl00_PlaceHolderMain_ctl01__ControlWrapper_RichHtmlFiel‌​d'); The web parts I need to add to tabs are all inside the RichHtmlField, generated from the custom page layout. Took some trial-and-error to understand how your clever code worked. –  Alex C Sep 11 '11 at 6:22
add comment

Your Answer


