I currently have a macro that is contained in my main template - however, I'd like to only display this Macro if the current page belongs to a normal "TextPage" doc type. As opposed to showing it on "News Items", "Blog Posts" and so on. Is there any sort of logic I can add to my template to say:
if textpage { show the macro }
Or is this done via XSLT only? If it is XSLT only - does anyone have any articles that contains any code for this?
unfortunately not having any luck with the above code. I have added it to the template but when I refresh the website page it is just showing the code as text in the page. I am having to use Umbraco version 3.0 due to client development restrictions, so I wonder if the styntx is incompatible with this earlier version of umbraco?
Can you put logic (if, else etc) into Templates?
Hi everyone,
I currently have a macro that is contained in my main template - however, I'd like to only display this Macro if the current page belongs to a normal "TextPage" doc type. As opposed to showing it on "News Items", "Blog Posts" and so on. Is there any sort of logic I can add to my template to say:
if textpage { show the macro }
Or is this done via XSLT only? If it is XSLT only - does anyone have any articles that contains any code for this?
Cheers,
Garry.
Garry,
If your template add the following
<%@ Import Namespace="umbraco.presentation.nodeFactory" %>
<script runat="server">
Node current=null;
void Page_Load(){
current=Node.GetCurrent();
}
</script>
then further down where you want to show the macro
<%if(current.NodeTypeAlias=="TextPage"){%>
<umbraco:Macro startingLevel="2" recurse="1" selectBranches="1"
maxMenuDepth="2" ulBaseClass="" branchClass="branch"
selectedClass="selected" forceNode="" expandChildren="1"
forceHome="0" securityTrimming="1" Alias="[COG]Navigation" runat="server">
</umbraco:Macro>
<%}
obviously replace the macro code with your macro.
Regards
Ismail
unfortunately not having any luck with the above code. I have added it to the template but when I refresh the website page it is just showing the code as text in the page. I am having to use Umbraco version 3.0 due to client development restrictions, so I wonder if the styntx is incompatible with this earlier version of umbraco?
Ah you may have a problem then as i think the old v3 templates are not .net master page templates.
ok thanks Ismail, we sorted it by just using some different templates for our different doc types - thanks for the help!
is working on a reply...