Feb 1 2011

Supporting optional mobile theming in [BE]

Category: .NetRory Primrose @ 11:23

I posted a feature request on the BlogEngine.Net CodePlex site a few weeks ago because I wanted the ability for mobile users to opt in and out of using the mobile theme. The primary reason for this was that I wanted to be able to access the admin features of my own blog from my phone from time to time. This was not easily possible using the standard mobile theme.

I figured it wouldn’t be too hard to implement so I bashed it out yesterday and pushed up a fork. The change has been accepted by rutr who added it to the BlogEngine.Net codebase.

I modified the mobile theme to include a “Regular Site” link at the top of the page as highlighted below.

Each theme provided in the BlogEngine.Net installation has also been updated to display a “Mobile Site” link in the most appropriate place for the theme. I’m using the fantastic Stardust theme which I have also modified in a similar manner as highlighted below.

image

I changed the header links in the stardust site.master page with the following:

<ul >
    <li <%=MenuClass("default.aspx")%>><a href="<%=Utils.AbsoluteWebRoot %>" rel="home"><%=Resources.labels.home %></a></li>
    <li <%=MenuClass("archive.aspx")%>><a href="<%=Utils.AbsoluteWebRoot %>archive.aspx"><%=Resources.labels.archive %></a></li>
    <li <%=MenuClass("contact.aspx")%>><a href="<%=Utils.AbsoluteWebRoot %>contact.aspx"><%=Resources.labels.contact %></a></li>
      <% if (Utils.IsMobile)
 { %>
      <li><blog:MobileThemeSwitch ID="MobileThemeSwitch1" runat="server" /></li>
      <%
 }
      %>
    <li <%=MenuClass("account/login.aspx")%>><a runat="server" id="aLogin" /></li>
</ul>

This change is similar to the changes made to the standard BlogEngine.Net themes. The theme adds a new custom control to the page if the device is a mobile device. This custom control displays a link button that actions the theme switch.

You can check out this functionality by hitting this site with a mobile device.

Tags:

Comments (1) -

1.
Rory Primrose Rory Primrose Australia says:

If you want these changes now, you will need to take a build of the current BlogEngine.Net source. This is because there were some changes to the core BlogEngine.Net libraries in order to achieve this functionality. The alternative is to wait for the next BlogEngine.Net release.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading