Copied to clipboard

Flag this post as spam?

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


  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 16:40
    Dominic Brown
    0

    Ulitmate Picker?

    Good afternoon all!

    I am trying to create a Services page where the end user can add their own thumbnail and text (as many times as they like).

    I am pretty new to Umbraco but i came accross the video for the Ulitmate Picker and thought this might be what i need, but i am unsure if it is and i can't seem to get it working.

    So this is what i have done so far:

    In the "Content" section i've created this, i've highlighted in bold the pages in question:

    Content
    - Homepage
      -- About Us
      -- Services
         --- MOT
         --- Recon
         --- Service

      -- Contact Us

    I've created an ulitmate picker called Services (db type Nvarchar, Type CheckBoxList) and linked it to the parent id 1087 (Services).

    I then created a doc type called Main Services and added a tab and inserted the ulitmate picker and then added it to the template (  <umbraco:Item field="selectedServices" runat="server"></umbraco:Item> )

    Next i created a doc type called Services and gave it an uploader (thumbnail) and simple editor (details), i then created the sub pages MOT, Recon and Service.


    Now, this has allowed me to display the id's of the sub pages in the services page (1088,1089,1090, which is a good start.

    According to Umbraco.tv i need to create an XSLT file which contains the following:

      <xsl:for-each select="umbraco.library:Split($currentPage/data[@alias='selectedServices'],',')//value">
        
        <xsl:value-of select="selectedServices"/>
        
        <xsl:value-of select="umbraco.library:GetXmlNodeById(.)/@nodeThumbnail" />
      </xsl:for-each>

    Now, this does nothing at all so far!! I've then added the macro into the main services template but still nothing.

     

    Can anyone please help?

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 16:44
    Rich Green
    1

    Hey Dominic,

    Firstly, that video must be out of date as the XSLT above is for pre 4.5 versions of Umbraco.

    You can upgrade the XSLT here http://blackpoint.dk/umbraco-workbench/tools/convert-xml-schema-to-45-.aspx

    Maybe give that a try and let us know how you get on.

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 16:49
    Dominic Brown
    0

    thats a handy page!!

    new cod:

    <xsl:for-each select="umbraco.library:Split($currentPage/selectedServices,',')//value">

    <xsl:value-of select="selectedServices"/>

    <xsl:value-of select="umbraco.library:GetXmlNodeById(.)/@nodeThumbnail" />
    </xsl:for-each>

    Still not working :s

    Is the @node bit correct? "@nodeThumbnail", i'm thinking that should be something else?

     

    thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 11, 2011 @ 16:56
    Jan Skovgaard
    0

    Hi Dominic

    I'm suspicious that the @nodeThumbnail attribute in fact exists in the XML you get returned. But it's a bit hard to tell since we don't have any clue what the XML returned looks like.

    What do you get returned if you write this...

    <textarea>
    <xsl:copy-of select="umbraco.library:Split($currentPage/selectedServices,',')" />
    </textarea>

    (If you get something returned then either copy/paste the XML into an editor or just make the textarea larger).

    /Jan

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 16:58
    Rich Green
    0

    Hey,

    It's probably something more like:

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
    <xsl:for-each select="$
    services/value">

    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
    <xsl:variable select="$currentNode/nodeThumbnail" />

    </xsl:for-each>         

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:04
    Dominic Brown
    0

    Jan:

    I replaced my code with yours and this is what i got the below in a small text box

    <values><value>1088</value><value>1089</value><value>1090</value></values>

     

    Rich:

    I get errors on that code,

    Error occured

    System.Xml.Xsl.XslLoadException: Missing mandatory attribute 'name'. An error occurred at C:\Users\dombrown\Documents\My Web Sites\Umbraco Engine Reconditioner\xslt\634459968732824597_temp.xslt(21,2).
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 11, 2011 @ 17:07
    Jan Skovgaard
    0

    Hi Dominic

    Ok, try altering Rich's sample to this

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
    <xsl:for-each select="$services//value">

    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
    <xsl:value-of select="$currentNode/nodeThumbnail" />

    </xsl:for-each>

    /Jan

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:12
    Dominic Brown
    0

    I still just get the id's 1088,1089,1090on the services page

    Could there be another area which i've done something incorrectly do you think?

     

    thanks

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:14
    Dominic Brown
    0

    Also, do you both think i am doing the right think for my desired output?

    I was thinking the end user could just right click on the services page, create and subpage using the doc type with the thumbnail and details and that would insert it into the page?

    thanks again

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 17:15
    Rich Green
    0

    Which version of Umbraco are you using? My code example looks fine from here.

    Rich

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 17:17
    Rich Green
    0

    Hey,

    Re: your question above, this is a ok solution, however I would use http://ucomponents.codeplex.com/wikipage?title=RenderTemplates

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:22
    Dominic Brown
    0

    i'm on 4.7.0

    so it must be somewhere else i'm making a mistake?

     

    i'll check that out, thanks

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 17:25
    Rich Green
    0

    Sorry, I hand typed it, try this

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
    <xsl:for-each select="$services/value">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
    <xsl:value-of select="$currentNode/nodeThumbnail" />
    </xsl:for-each

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:29
    Dominic Brown
    0

    Still not working lol

    Is my template correct?

     

    <%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderId="cp_content" runat="server">

    <div id="mainServices">
      <umbraco:Macro Alias="SelectedServices" runat="server"></umbraco:Macro>

      </div>
    </asp:Content>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 11, 2011 @ 17:33
    Jan Skovgaard
    0

    Hi Dominic

    The template looks allright to me.

    What happens if you change this...<xsl:for-each select="$services/value">

    to <xsl:for-each select="$services//value"> ?

    /Jan

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:38
    Dominic Brown
    0

    nothing lol

    fyi, the id's were only appearing before because i left some field code for selectedServices in the template, i've now removed that and i get nothing

    Must be going wrong somewhere ;s

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:40
    Dominic Brown
    0

    I have another template for Services (sub services), is this correct?

     

    <%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>




      
    <asp:Content ContentPlaceHolderId="cp_content" runat="server">



        <div id="services">  
                  
                <div id="thumbnail">  
          <umbraco:Item field="thumbnail" runat="server"></umbraco:Item>
          
      </div>
      
      <div id="details">
          <umbraco:Item field="details" runat="server"></umbraco:Item>
                  

      </div>
      </div>
    </asp:Content>

  • Dominic Brown 91 posts 111 karma points
    Jul 11, 2011 @ 17:57
    Dominic Brown
    0

    I'm going to try this ucomponent, it looks really good, and there is a video which is great for noobs like me lol

    Will let you both know how it goes

     

    thanks

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 18:25
    Rich Green
    0

    Seems like you were pretty close with your last solution!

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 10:34
    Dominic Brown
    0

    You think?

    I was thinking more about it and in the XSLT i had to name the node, that would mean i'd have to name it for each instance right? Thats no good for when the end user creates a new service.

    I could be wrong tho, my knowledge is limited lol

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 11:15
    Jan Skovgaard
    0

    Dominic I think it seems like you are playing around with too many things at the moment :-)

    Let's try to just focus on getting the XSLT macro to work without playing around with the template hierachy.

    In one of the earlier posts we saw that you got the XML with <values><value>id</value></values> out correctly. Not it should be interesting to see what the XML returned for each selected instance looks like.

    So try writing the code below and then please just insert it on your mastertemplate and see what gets returned. Then you can deal with the template hierachy and inheritance stuff later :-) (Please notice it has been altered a bit where I have highlighted it! - I have also inserted a textarea, which will write all the XML for the selected nodes so we can figure out if the nodeThumbnail element exist in the XML you're trying to match or not. And after each <xsl:value-of select="" /> I've inserted "- test", to see if the loop is running. If only test is returned the loop is working fine but the element we're trying to get the value from does not exist.)

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
    <xsl:for-each select="$services//value">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />

    <textearea>
    <xsl:copy-of select="$currentNode" />
    <xsl:comment />
    </textarea>
    <br />

    <xsl:value-of select="$currentNode/nodeThumbnail" /> - test<br />

    </xsl:for-each>

    Do you get any XML written in the <textarea>'s?

    Try to give this a go and please do it on the master template just to see if you get anything returned. Once it's working you can deal with placing it in the correct template later.

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 11:19
    Dominic Brown
    0

    Hi,

    I just had a breakthrough, i removed the nodeThumbnail from the end and it now outputs the image location and the random text i entered in the details section.

    /media/747/engine_recon.gifLorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a orci a ipsum luctus laoreet vitae dignissim erat. Donec odio ligula, elementum vel imperdiet at, imperdiet eget lorem. Quisque nec libero dui. Nulla et vestibulum nisl. Nulla ut lectus turpis. Morbi suscipit, magna ac laoreet vestibulum./media/749/engine_recon.gifLorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a orci a ipsum luctus laoreet vitae dignissim erat. Donec odio ligula, elementum vel imperdiet at, imperdiet eget lorem. Quisque nec libero dui. Nulla et vestibulum nisl. Nulla ut lectus turpis. Morbi suscipit, magna ac laoreet vestibulum./media/751/ic_engine.jpgLorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a orci a ipsum luctus laoreet vitae dignissim erat. Donec odio ligula, elementum vel imperdiet at, imperdiet eget lorem. Quisque nec libero dui. Nulla et vestibulum nisl. Nulla ut lectus turpis. Morbi suscipit, magna ac laoreet vestibulum.

    I used this code

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
      <xsl:for-each select="$services/value">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
        <xsl:value-of select="$currentNode" />
    </xsl:for-each>

    Now, the question is, why the image location and not the image itself and is it linked to a template?

    thanks

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 11:20
    Dominic Brown
    0

    Hi Jan,

    Sorry, just saw your reply after i posted mine lol

    Does what i've done answer your post?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 11:26
    Jan Skovgaard
    1

    Hi Dominic

    Ok that's cool - so now we just need to figure out what the rendered XML looks like.

    Using the code you have posted above try just wrapping the $currentNode in <textarea><xsl:copy-of select="$currentNode" /></textarea> instead of the <xsl:value-of select="$currentNode" />

    This should give you some textarea's where you can see the XML for each of the selected nodes.

    Once you know the structure of the returned XML you know, which parts you should try to select.

    /Jan

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 11:31
    Dominic Brown
    0

    ok, i have 3 textboxes with my dummy data, here is a sample of one

    <Services id="1088" parentID="1087" level="3" writerID="0" creatorID="0" nodeType="1074" template="1075" sortOrder="1" createDate="2011-07-11T13:16:07" updateDate="2011-07-11T13:26:04" nodeName="MOT" urlName="mot" writerName="admin" creatorName="admin" path="-1,1048,1087,1088" isDoc=""><thumbnail>/media/747/engine_recon.gif</thumbnail><details>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a orci a ipsum luctus laoreet vitae dignissim erat. Donec odio ligula, elementum vel imperdiet at, imperdiet eget lorem. Quisque nec libero dui. Nulla et vestibulum nisl. Nulla ut lectus turpis. Morbi suscipit, magna ac laoreet vestibulum.</details></Services>

  • Rich Green 2246 posts 4008 karma points
    Jul 12, 2011 @ 11:35
    Rich Green
    0

    Dominic, 

    The problem was your property is called 'thumbnail' so change your code to this and you should see a list of thumbnails.

    <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
      <xsl:for-each select="$services/value">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
           <xsl:value-of select="$currentNode/thumbnail" />
    xsl:for-each>

    Good effort Jan for getting this far!

    Rich

     

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 11:40
    Dominic Brown
    0

    yeah, i can enter thumbnail or details and it displays each, or if i put nothing it displays it all.

    I had a feeling it was that nodename bit that was causing this, i tried a few different things last night with it but then this morning i removed the node and it worked lol

     

  • Rich Green 2246 posts 4008 karma points
    Jul 12, 2011 @ 11:46
    Rich Green
    0

    Excellent, glad you got it working.

    If you could mark one of Jans posts as the solution to help anyone else who has a similar problem, and just to say thanks too :) 

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 11:50
    Dominic Brown
    0

    Done and done!

    Thanks alot to you both!!

    Now i just have to figure out how to display it all how i want lol

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 12:19
    Dominic Brown
    0

    The umbraco.tv video on this does not show you how to format the output of the content :o(

    any ideas on where i can find out how to do this guys?

    i need have it looking like this

    thumbnail - details
    thumbnail - details
    thumbnail - details

    and then when a new one is created it just slots in below

    thanks again

     

     

  • Rich Green 2246 posts 4008 karma points
    Jul 12, 2011 @ 12:20
    Rich Green
    0

    What do you need your output to look like?

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 12:23
    Dominic Brown
    0

    I need the thumbnail on the left with supporting details to the right and then the same under that for each new service added

    Dom

  • Rich Green 2246 posts 4008 karma points
    Jul 12, 2011 @ 12:25
    Rich Green
    0

    I mean the HTML, do you have some HTML which displays what you need?

    Rich

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 12:31
    Dominic Brown
    0

    you mean in the templates right?

    I have 2 templates, Main Services and Services

    Main Services:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderId="cp_content" runat="server">

    <div id="mainServices">
      <umbraco:Macro Alias="SelectedServices" runat="server"></umbraco:Macro>
    </div>
    </asp:Content>

     

    Services:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/MainServices.master" AutoEventWireup="true" %>




      
    <asp:Content ContentPlaceHolderId="cp_content" runat="server">



        <div id="services">  
                  
                <div id="thumbnail">  
                <umbraco:Item field="thumbnail" runat="server"></umbraco:Item>
          
      </div>
      
      <div id="details">
    <umbraco:Item field="details" runat="server"></umbraco:Item>
    </div>
    </div>
    </asp:Content>

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 12:32
    Dominic Brown
    0

    i set it up like this at the start because i thought i'd need to have different div tags for thumbnails and details so i could use them both in the stylesheets, but as you will see its only outputting the details from the macro in Main Services

  • Dominic Brown 91 posts 111 karma points
    Jul 12, 2011 @ 14:36
    Dominic Brown
    0

    its ok guys, i sorted it. I wasn't aware i could use html tags in the xslt!!

    here is the code i used to sort it

    <table border="0">
      <xsl:variable name="services" select="umbraco.library:Split($currentPage/selectedServices, ',')" />
      <xsl:for-each select="$services/value">
        <tr>
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)" />
          <td>
            <img>
            <xsl:attribute name="src">
           <xsl:value-of select="$currentNode/thumbnail" />
            </xsl:attribute>
          </img>
          </td>
         <td valign="top"><xsl:value-of select="$currentNode/details" /></td>
      </tr>
      </xsl:for-each>

      </table>

     

     

    thanks you both, you've been legendary

Please Sign in or register to post replies

Write your reply to:

Draft