Copied to clipboard

Flag this post as spam?

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


  • marthin 87 posts 106 karma points
    Nov 09, 2010 @ 10:59
    marthin
    0

    Inherent Logo from top node

    Hi,

     

    Im trying to let my users select there own logo in a top node, I then whant that same logo to be available to all sub pages.

    This is my current structure:

    1. TopPage (select logo)

        1.1 About us

        1.2 My Extra Page

     

    So if i select a logo in the generics tab on top page, iv set it to a master template that all pages inherent from but when i go to the page "about us" or "my extra page" then the logo cant be found, since its trying to access the generics value that only can be found if im at "TopPage".

     

    Current code for master template

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="master_white.Master.cs" Inherits="MyProject.masterpages.publicMasters.master_white" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
        <link rel="Stylesheet" type="text/css" href="/css/master_white.css" />
         <link rel="Stylesheet" type="text/css" href="/css/jquery.treeview.css" />
      <script type="text/javascript" src="/scripts/jquery-1.4.1.js"></script>
        <asp:ContentPlaceHolder ID="HeadContentHolder" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="Container">
            <div id="TopContent">
                <div id="TopMenu">
                    <div>
                        Välkommen! <a href="/">Logga in</a> eller <a href="/">Ny Kund</a>
                    </div>
                    <asp:ContentPlaceHolder ID="TopMenuContentHolder" runat="server" />       
                </div>
                <div id="TopLogoShopping">
                    <div id="LogoArea">                  
                       <umbraco:Item runat="server" field="logotyp" xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')" xsltDisableEscaping="true" />
                        <asp:ContentPlaceHolder ID="LogoAreaContentHolder" runat="server" />
                    </div>
                    <div id="ShoppingBag">
                        <img src="/images/webshop/shopping_cart.png" alt=""/> <h3>Varukorg</h3>                
                    </div>
                </div>
                <div id="MainMenu">        
                    <asp:ContentPlaceHolder ID="MainMenuContentHolder" runat="server" />
                </div>
            </div>
            <div id="BodyContent">
                <asp:ContentPlaceHolder ID="BodyContentHolder" runat="server" />
            </div>
            <div id="FooterContent">
                <asp:ContentPlaceHolder ID="FooterContentHolder" runat="server" />
            </div>        
        </div>
        </form>
    </body></html>

     

    I at first tried to let the TopPage have a master document type and then let the other sub pages have a child document type so that it would have the same generics, but this would force my users to select the same logo for all pages. This is not an option.

     

    Please do help!

    Best Regards

    Marthin

  • John C Scott 473 posts 1183 karma points
    Nov 09, 2010 @ 13:12
    John C Scott
    0

    i am not sure how this is working - 

     

    concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')

     

    where you have GetMedia({0},'true')

    i assume the {0} comes from the  field="logotyp"

    this will only work for the current page

    this isn't the way I'd normally do this but I can see that it could work

    maybe you were intending to add recursive="true" to the Umbraco:Item element?

    this will mean that if the field is not filled or present on the current page it will search backwards through the page's ancestors until it finds a page with this value

    so then the sub-pages will use the value set on the home page parent

    I've not tried this approach but it looks like it should work and so your Umbraco:Item element would change to

     

    <umbraco:Item runat="server" field="logotyp" recursive="true" xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')" xsltDisableEscaping="true" />

     

  • marthin 87 posts 106 karma points
    Nov 09, 2010 @ 14:31
    marthin
    0

    Hi, I did as you said and added

    recursive="true" 

    That solved everything

    Thanks for the help!

  • John C Scott 473 posts 1183 karma points
    Nov 09, 2010 @ 15:01
    John C Scott
    0

    excellent - my 2nd ever solution ! starting to enjoy this... glad to be able to help

Please Sign in or register to post replies

Write your reply to:

Draft