开发者

How to create a "sidebar" in Umbraco CMS?

In Umbraco, every page has a content field that you can edit in the admin-area. What I want would be a second content field that I (actually my customer who will be editing the content by himself) can edit on every page. I would then create a masterpage/template that contains the two content areas (the first开发者_如何学C one as the main content and the second one as the sidebar). At least this is how I would do it. Is this possible or is there even a better approach for having a main content and a separate sidebar on every page?


Answer found, it is super easy: Add a rich text editor property to the runway text page and have your markup like this:

<table style="font-size: 13px; line-height: 1.5em;">
    <tr>
        <td class="innerTD">
            <div style="min-height:600px; width: 465px;">
<div id="contentHeader">    
    <h2><umbraco:Item runat="server" field="pageName"/></h2>
</div>

                <form id="RunwayMasterForm" runat="server">
                    <umbraco:Item runat="server" field="bodyText" />
                </form>
            </div>
        </td>
        <td style="width: 250px; padding: 8px;">
            <umbraco:Item runat="server" field="sidebarText" />
        </td>
    </tr>
</table>

notice <umbraco:Item runat="server" field="sidebarText" />


Generally, yes.

Add a new tab to the Document Type that you want to add a sidebar to (called Sidebar or something). Then add a new property or set of properties to that tab to manage the content.

Then in your templates simply add the sidebar to the markup (and edit the CSS to style the new markup) and add your new fields to the template.

In the case above it's this line: <umbraco:Item runat="server" field="sidebarText" />

You can also have a default sidebar setting on the home page or any parent item that contains the sidebar info by recursively getting that value. Thus, if the "sidebarText" field on the current page is empty, it would use its parent. That makes managing the content a little easier on a large site and you can change just what you need on the specific page with differences.

The recursive setting is just a check box in the dialog to add an item to a template.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜