Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ryan Green 63 posts 83 karma points
    Dec 05, 2012 @ 17:05
    Ryan Green
    0

    Conditional field based on the nodeID of a page

    I want to put some conditional code (in this case h1 styling) based on if the page is the home page or not of the site. My ID of the home page is 1163, so I would like the h1 to show up in one place, if it isn't the home page, for it to show up in a different place. You would think this would be really easy to accomplish, but being the nOOb that I am, I cannot for the life of me figure out how to do it on my page template. Here is the code I am using, it throws no error, just doesn't do anything.

     

    <umbraco:Macro Alias="YourMacroAlias" runat="server" YourPropertyName="[#pageID]">

    if(YourPropertyName == "1163")
    {
    <h1 style="float:right; width:570px;">  
    }
    else
    {
    <h1 style="padding-left:32px;">
    }                                                                
    </umbraco:Macro

  • Ryan Green 63 posts 83 karma points
    Dec 05, 2012 @ 20:14
    Ryan Green
    0

    I guess, I sort of figured it out. 

     

      <if (umbraco.presentation.nodeFactory.Node.GetCurrent().Id =1163) %>
        <h1 style="padding-left:32px;"><font color="004a8c"><umbraco:Item field="pageTitle" runat="server" /></font></h1
        <%>
          
      <if (umbraco.presentation.nodeFactory.Node.GetCurrent().Id !1163) %>
      <h1 style="float:right; width:570px;"><font color="004a8c"><umbraco:Item field="pageTitle" runat="server" /></font></h1>
        <%>

Please Sign in or register to post replies

Write your reply to:

Draft