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:
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.
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?
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.
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.)
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.
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.
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.
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>
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
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
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?
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
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
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
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
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)
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
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
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
Which version of Umbraco are you using? My code example looks fine from here.
Rich
Hey,
Re: your question above, this is a ok solution, however I would use http://ucomponents.codeplex.com/wikipage?title=RenderTemplates
Rich
i'm on 4.7.0
so it must be somewhere else i'm making a mistake?
i'll check that out, thanks
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
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>
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
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
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>
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
Seems like you were pretty close with your last solution!
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
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.
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
Hi Jan,
Sorry, just saw your reply after i posted mine lol
Does what i've done answer your post?
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
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>
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
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
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 :)
Done and done!
Thanks alot to you both!!
Now i just have to figure out how to display it all how i want lol
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
What do you need your output to look like?
Rich
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
I mean the HTML, do you have some HTML which displays what you need?
Rich
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>
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
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
is working on a reply...