Actually, it seems that you want to show some kind of a 'breadcrumb' in the tittle of the page, so probably it could be easier just to create a macro for it and to use it in the top-level template.
Ok, so I think it'll be more correct to go another way.
What does this drop-down list do? (Definitely it has to do something - like changing some property of something, or setting a coockie or something like this). Since that you can extract the value in need from the result of what the drop-down does.
Actually, in Umbraco a macro is supposed to be like 'the thing in itself' and there's nothing a standard way of making macros communicate each other. Probably it would be great to have such a thing as a part of Umbraco framework - something like 'connected properties' in the WebParts framework, but by now there's still nothing like this.
Master and sub Templates
hello
say I have MasterTemplate and created ChildTemplate under it.
In master doc type there is property name title.
Now my requirement is if page is created from MasterTemplate then it should take title tag as follows:
<title><umbraco:Item field="title" runat="server"></umbraco:Item></title>
and if page is created from ChildTemplate then it should take title as follows: (i.e. override above title tag)
<title><umbraco:Item field="title" runat="server"></umbraco:Item> | <%=HttpContext.Current.Request["category"]%> | <%=HttpContext.Current.Request["searchtext"]%> | <%=HttpContext.Current.Request["page"]%></title>
How can I do that?
It can be done the same way as in any regular ASP.NET application.
Define some separate placeholder for title, e.g. in the master template and give them default content (in your case i will be a field control):
<title>
<asp:ContentPlaceHolder runat="server" ID="phTitle">
<umbraco:Item field="title" runat="server"/>
</asp:ContentPlaceHolder>
</title>
and give this content placeholder another content in the child template:
<asp:Content runat="server" ContentPlaceHolderID="phTitle">
<umbraco:Item field="title" runat="server"/>
| <%=HttpContext.Current.Request["category"]%>
| <%=HttpContext.Current.Request["searchtext"]%>
| <%=HttpContext.Current.Request["page"]%>
</asp:Content>
Actually, it seems that you want to show some kind of a 'breadcrumb' in the tittle of the page, so probably it could be easier just to create a macro for it and to use it in the top-level template.
thank you.. I will check out
hey .. that works.. But Iwant to modify the same a bit. I want to check querystring param to be null. If null then dont want to append that in title.
Very simple:
hey thanks ....
similarly can I access dropdown list value ? this control is on my page.. .say I want to append drplang.selectedValue.
Sure, you can insert any valid statement that returns some value between <%= and %> and the result of its calculation will be rendered there.
can you give me one example please ....
Here's the simplest sample:
<%= drplang.selectedValue %>
And here's some details about '<% %>' blocks on MSDN:
http://msdn.microsoft.com/en-us/library/k6xeyd4z.aspx
hey ... its not working... It is giving error: The name 'drplang' does not exist in the current context ... following is the code in sub-template
<%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" %>
<asp:Content runat="server" ContentPlaceHolderID="phTitle"><%= drplang.selectedValue %><umbraco:Item field="title" runat="server"></umbraco:Item><%=(Request.QueryString.Count > 0)?
" - " + (HttpContext.Current.Request["lang"]== null ? string.Empty : HttpContext.Current.Request["lang"]+" ")
</asp:Content>
Oh, defenitely it's supposed that you should have a DropDownList control with the ID = drplang somewhere in the same template.
actually on this template I have macro which is of .ascx file and this .ascx has drplang dropdown. So, now can you help me how can I access its value?
I think, you can try to assign some ID to the Macro control and to find the dropdown with the 'Find' method.
<%= ((DropDownList)myMacro.Find("drplang")).SelectedValue %>
....
bla-bla-bla
......
<umbraco:Macro ID="myMacro" runat="server" ..... />
Actually on document type I have macro container in which I select macro whichever I need on the page. So, how can I proceed now?
I tried this <%= ((DropDownList)this.FindControl("drplang")).SelectedValue %> ... then it shows
Object reference not set to an instance of an object.
Ok, so I think it'll be more correct to go another way.
What does this drop-down list do? (Definitely it has to do something - like changing some property of something, or setting a coockie or something like this). Since that you can extract the value in need from the result of what the drop-down does.
Actually, in Umbraco a macro is supposed to be like 'the thing in itself' and there's nothing a standard way of making macros communicate each other. Probably it would be great to have such a thing as a part of Umbraco framework - something like 'connected properties' in the WebParts framework, but by now there's still nothing like this.
is working on a reply...