Sitecore navigation user control? - sitecore

Could you please provide some working examples for navigation in sitecore using user control instead of xslt rendering since I do not find a good one on sitecore sdn ?
thanks

One example:
http://www.launchsitecore.net/en/about-launch-sitecore/building-the-site/creating-the-site-menu
Markup
<ul class="nav">
<asp:Repeater ID="rptDropDownMenu" runat="server" OnItemDataBound="rptDropDownMenu_ItemDataBound">
<ItemTemplate>
<li id="MenuLi" runat="server">
<asp:HyperLink ID="MenuLink" runat="server">
<asp:Literal ID="MenuText" runat="server" />
</asp:HyperLink>
<asp:PlaceHolder ID="phSubMenu" runat="server" />
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
Code Behind
HomeItem = SiteConfiguration.GetHomeItem();
List<item> nodes = new List<item>();
if (HomeItem["Show Item In Menu"] == "1") nodes.Add(HomeItem);
foreach (Item i in HomeItem.Children)
{
if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item In Menu"] == "1")
{
nodes.Add(i);
}
}
rptDropDownMenu.DataSource = nodes;
rptDropDownMenu.DataBind();

Related

How to have the border in a div appear only if Webpart zone has a webpart in it>

I have a webpart wrapped in a div that has a border applied to it (class="wpz-1"). The border appears on the page regardless if the webpart zone has a webpart in it or not. How can I make the border appear only if the webpart zone has a webpart in it?
<div class="wpz-1">
<div data-name="WebPartZone">
<!--CS: Web Part-->
<!--SPM:<%#Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
<div xmlns:ie="ie">
<!--MS:<WebPartPages:WebPartZone runat="server" AllowPersonalization="false" ID="x8600600cbb2046468f9615155e5fd921" FrameType="TitleBarOnly" Orientation="Vertical" >-->
<!--MS:<ZoneTemplate>-->
<!--DC: - Web Part -->
<!--ME:</ZoneTemplate>-->
<!--ME:</WebPartPages:WebPartZone>-->
</div>
<!--CE: Web Part-->
</div>
</div>
You could try to change the div attribute based on child elements of your zone(if no webpart in webpart zone, it will not display based on my testing, so check the webpart zone to confirm whether there is webpart inside <div customAttr="customAttr").
Just demo:
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<style>
.wpz-1{
border:1px fuchsia groove;
}
</style>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
$(function () {
if ($('div.ms-webpart-zone', 'div[customAttr="customAttr"]').length < 1) {
$('div.wpz-1').removeClass("wpz-1");
}
})
</script>
<WebPartPages:SPProxyWebPartManager runat="server" id="spproxywebpartmanager"></WebPartPages:SPProxyWebPartManager>
<p></p>
<div class="wpz-1">
<div data-name="WebPartZone">
<div customAttr="customAttr" xmlns:ie="ie">
<WebPartPages:WebPartZone runat="server" AllowPersonalization="false" ID="x8600600cbb2046468f9615155e5fd921" FrameType="TitleBarOnly" Orientation="Vertical" >
<ZoneTemplate>
<!--DC: - Web Part -->
</ZoneTemplate>
</WebPartPages:WebPartZone>
</div>
</div>
</div>
</asp:Content>

How to click a link-to table row using ember.js?

I've got what should be a working example - moving the link-to from the anchor to the table row itself
<table class="table table-hover">
<tbody>
{{#each customer in controller}}
{{#link-to 'customer' customer.id tagName="tr"}}
<td>
<a {{bind-attr href="view.href"}}>click</a>
</td>
{{/link-to}}
{{/each}}
</tbody>
</table>
Using mobile safari when I browse this page and "click" a table row it highlights the "color" of the row (bootstrap table-hover styling) so I know it's seeing that I've touched the row ... yet it won't jump to the route (unless I click the link itself)
How can/should I do a clickable table row with ember's link-to?
also -I'm using fastclick on the site to reduce the 300 ms delay and I killed zoom
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
add the css
td a {
display:block;
width:100%;
}
Add also:
tr {
cursor: pointer;
}

How to access child controller of hasMany

I would like to trigger an action on the ArrayController of child elements in the parent view. How would I go about that?
Specifically, I am trying to add a new child element to a hasMany relationship. It works fine using {{action new}} in the view of the child elements, but I am not sure how to do this from the parent view.
<script type="text/x-handlebars" data-template-name="parents">
<b>List</b><br />
{{#each parent in controller}}
{{ parent.name }} <br />
{{ render "kids" parent.children }}
<a href="#" {{ action parent.children.new target="controller" }}>Parent View Make Kid</a<br/>
<br />
{{/each}}
</script>
<script type="text/x-handlebars" data-template-name="kids">
{{#each kid in controller}}
> {{ kid.name }} <br />
{{/each}}
<a href="#" {{ action new }}> Kid Controller Make Kid</a><br />
</script>
In the above "Kid Controller Make Kid" works fine, "Parent Controller Make Kid" does not.
Please find a fiddle illustrating the problem here: http://jsfiddle.net/chopper/zHnQC/2/
Thanks!
From the parent's view you can't access directly to the children's controller like that. I think the best option would be to implement a newKid method on ParentsController responsible to create the new record on its model.
I've forked your fiddle and implemented a working example: http://jsfiddle.net/pxkys/1/
Hope this helps!

sitecore: editframe

I need to use editframe to let the front user to modify some checkbox fields
I create a new edit frame button and set only those fields that I want front user to edit. For example : Core DB -> /sitecore/content/Applications/WebEdit/Edit Frame Buttons/(edit button folder)/(field editor button). In the fields to be edited by front user, I have set it to Headline.
In my sublayout, I have this code
<sc:EditFrame ID="EditField" runat="server" Buttons="/sitecore/content/Applications/WebEdit/Edit Frame Buttons/EditFields">
<div id="whatyoumissed">
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<ul style="list-style-type: none;" >
<asp:PlaceHolder runat="server" ID="itemplaceholder"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li style="float: left;margin-left:20px;">
<sc:FieldRenderer ID="FieldRenderer2" runat="server" FieldName="Headline"
Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" /> <br />
<sc:FieldRenderer ID="FR3" runat="server" FieldName="cb" Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" />
</li>
</ItemTemplate>
</asp:ListView>
</div>
</sc:EditFrame>
Code behind
string queryPath = "/bla/bla/bla/bla/bla/bla/bla/bla/bla";
var item = sc.Context.Database.GetItem(queryPath);
var children = item.Children;
ListView1.DataSource = children;
ListView1.DataBind();
When I click on the edit frame in the page editor, the prompted box does not have the field (headline) for me to modify it. Any suggestion?
Answer:
I have google abit of sitecore edit frame datasource and end up with this link
http://blog.jan.hebnes.dk/2011/12/using-sitecore-editframe-with.html
Instead of using the code behind as shown by Martijn Bos, I modify my code from prev to the following.
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<ul style="list-style-type: none;" >
<asp:PlaceHolder runat="server" ID="itemplaceholder"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<sc:EditFrame ID="EditField" runat="server" Buttons="/sitecore/content/Applications/WebEdit/Edit Frame Buttons/EditFields"
DataSource="<%# ((Sitecore.Data.Items.Item)Container.DataItem).Paths.FullPath %>" >
<li style="float: left;margin-left:20px;">
<sc:FieldRenderer ID="FieldRenderer2" runat="server" FieldName="Headline"
Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" /> <br />
<sc:FieldRenderer ID="FR3" runat="server" FieldName="cb" Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" />
</li>
</sc:EditFrame>
</ItemTemplate>
</asp:ListView>
Have you tried setting the DatasSource of the Editframe?
e.g. EditField.DataSource = item.Paths.FullPath;
You almost there. Should not use "FullPath". Try this instead
DataSource="<%# ((Sitecore.Data.Items.Item)Container.DataItem).Paths.FullPath %>"

How to insert a asp:TabPanel inside a asp:Repeater?

When I try to execute the below code it gives me the error "There was an error rendering the control. Check to make sure all properties are valid".
Inner repeater works fine inside the tab container. But outer does not allow to have a tab panel within it.
Tab containers are not available in asp.net toolbox and therefore I installed Ajax tool kit and added that to Visual Studio and refer that Assembly as follows.
<%# Register Assembly="AjaxControlToolkit, Version=1.0.11119.25966, Culture=neutral,PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Repeater ID="ProjectRepeater" runat="server">
<ItemTemplate>
<cc1:TabContainer ID="TestTabContainer" runat="server">
<cc1:TabPanel ID="TestTabPanel" HeaderText="technologies" runat="server">
<ContentTemplate>
<asp:Repeater id="SkillsRepeater" runat="server">
<ItemTemplate>
<div class="project-technologies" id="SkillZone" runat="server">
<a id="skill" href='<%# "http://vingo/Pages/projectresults.aspx?k="+DataBinder.Eval(Container.DataItem, "Skill")%>' target="_blank"><%# DataBinder.Eval(Container.DataItem, "Skill")%></a>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
EDIT: Outer repeater code
<asp:Repeater ID="P" runat="server">
<ItemTemplate>
<cc1:TabContainer ID="TTC" runat="server">
<cc1:TabPanel ID="TTP" HeaderText="t" runat="server">
<ContentTemplate>
<asp:Repeater id="A" runat="server">
<ItemTemplate>
<%--Code--%>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</ItemTemplate>
</asp:Repeater>
Instead of a asp.nett Repeater I could use the below code and it did the expected work of a asp.net Repeater and flexibility is much higher than when using asp:Repeaters
function JsonPCallBack(result) {
for (var technology in result) {
$('body').append('<div OuterDiv id=OuterDivId><div class=project-technologies id=SkillZone><a id=skill href=http://vingo/Pages/projectresults.aspx?k=' + technology + 'target=_blank></a></div>');
}
}