WidgetZone and JavaScript

Topics: Controls
May 28, 2009 at 5:16 PM

I have two masterpages in my themes/standard folder of my website.

Both include the <blog:WidgetZone> control.  The problem I'm seeing though is that on one masterpage all the javascript works fine (after logging in, the edit link, the x to close section link, etc), but on the second masterpage none of it works.

If I look at the source of a page that uses the masterpage that works, it includes a bunch of .axd files.  The source of a page that uses the other masterpage does not include these .axd files.  I am making the guess that this appears to be the difference, as I can't see anything else that would, or wouldn't, make it work.

Do I need to add these manually into my master page, or is there something I'm missing that's not including these, and thus not making things work.

Thanks!

Coordinator
May 28, 2009 at 9:29 PM

It sounds like you're not logged in as an administrator when using the second master page?

If you're logged in as an administrator, and you do a View Source, you should find "widget.js" in there somewhere (if you do a search).

The widget.js file allows you to drag-and-drop the widgets (although drag-and-drop is no longer used in the latest build of BE -- as a side note).  But the Edit and X links should show up regardless of the widget.js file being sent to the browser.  The 'Edit' and 'X' links are outputted from the WidgetBase.cs file in the App_Code\Controls folder.  They are outputted (and the widget.js file is too) if you are logged in as an administrator ... and it shouldn't matter which theme you are using.

May 28, 2009 at 9:49 PM

I am logged in as an administrator.

I see the X and "edit" links, as well as the Administrator section at the bottom, and the drop down list to add other items to the WidgetZone.  None of this works though.  I also don't see a reference to widget.js when viewing the source.

It's pretty hacky, but I add the <script> tag that references js.axd with the path to blog.js (copied from the master page source that works) and now the features work.

It's the Standard theme, but it's a new masterpage my designer added.

 

Thanks for the response!

Coordinator
May 28, 2009 at 10:23 PM
Edited May 28, 2009 at 10:24 PM

I see.  As you've found, even if the X and Edit links are there, they won't do anything unless the widget.js file has been sent to the browser.

Based on the details you've provided, it sounds like the new page(s) the designer has added aren't inheriting from the BlogBasePage class.  This wouldn't be the master page, but the "content pages".  All the content pages in BE (default.aspx, contact.aspx, archive.aspx, etc) inherit from the BlogBasePage.  It's the BlogBasePage class in the BE Core that injects many things into the page -- including the <script> tag for the widget.js file.

As an example, in the default.aspx.cs file (the blog's main home page), this line of code below indicates that page is inheriting from BlogBasePage.

public partial class _default : BlogEngine.Core.Web.Controls.BlogBasePage

If these new pages the designer is creating aren't inheriting from BlogBasePage, there may be some other problems you run into as well.

May 28, 2009 at 11:30 PM

Awesome, was not aware of that.

I will check the code behind for these new pages in the morning and make sure they have the proper inheritance chain.  Thanks for your help!