|
|
Rank: Newbie
Joined: 8/4/2008 Posts: 13 Location: Doetinchem, The Netherlands
|
Hi! I'm trying to get some properties from a document I choose with the contentpicker. The document is retrieved by using the contentpicker, which let's people choose their own content on the page. The only thing I get from the contentpicker is the page ID. Code: <a href="{umbraco.library:NiceUrl($currentPage/data [@alias='featureId'])}"> Read more... </a>
Now I need some properties which are set on this document. It must be possible, because the standard navigation control works the same way, in retrieving the page title.
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Remco, Get the node you're after using Code:umbraco.library:GetXmlNodeById() Feed this function with the node Id returned from the content picker and query the node for those properties you need Code:<a href="{umbraco.library:GetXmlNodeById($id)/data [@alias='alias']}"> Read more... </a> Hope that helps, Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 8/4/2008 Posts: 13 Location: Doetinchem, The Netherlands
|
I think we're getting close.. The thing I want is: Code: <a href="{umbraco.library:NiceUrl($currentPage/data [@alias='featureId'])}"> {umbraco.library:GetXmlNodeById($id)/data [@alias='title']}"> </a>
title is a property set on the page, which is picked in the contentpicker. Right now it only shows this text, in stead of using the code... edit: owkee... I got it.. :) using: Code: <xsl:value-of select="{umbraco.library:GetXmlNodeById($id)/data [@alias='title']}" />
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Nice, You're on your way to guru-ishing your xslt skills /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,831 Location: MA, USA
|
Good job! One tid-bit... you don't need the {} braces when using a value-of. The {} braces are simply short-hand for the full xsl:value-of statement when you are inside the property of a non-xslt statement... such as in the href="{...}". The {} braces are very handy, though! cheers, doug.
MVP 2007-2009 - Percipient Studios
|
|
Rank: Newbie
Joined: 11/12/2008 Posts: 13 Location: Bombay
|
Hi,
I too want to do the same thing. Access the property stored in a document which is chosen as contentpicker but in user control. I am not using xslt. Can you please guide me how to do this using umbraco API. Needed this on urgent basis.
Thanks in advance, Manisha
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
hi Manisha, Pass the id of the document to the user control using the [#pageID] syntax in the macro and use the umbraco api (http://umbraco.org/apiDocs/) to get the document(node) and its properties. Hope this helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 11/12/2008 Posts: 13 Location: Bombay
|
Hi Dirk,
Thanks for quick response.
My ContentPicker page has a property called caption whose value i need to display in user control on the main page.
I am able to get the document via pageID selected using contentpicker as
Document document = new Document(pageID); //Where pageID is the id of contentpicker document selected.
but If i do document.getProperty("caption"), it is null. Also document.getProperties count is zero.
Am I missing something?
Thanks, Manisha
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Manisha, Might have been wrong in my previous post (Have already deleted those bits...) I think what you need is: Code:umbraco.presentation.nodeFactory.Node n = new umbraco.presentation.nodeFactory.Node(idOfNode) Or, it might be even possible to get the current node from within the user control using following code snippet: Code:Node currentNode = Node.GetCurrent(); Hope this helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 11/12/2008 Posts: 13 Location: Bombay
|
Hi Dirk,
Using Node currentNode = Node.GetCurrent(); it gives me the currentNode which is the page that holds the contentpicker page. I need the ContentPicker page node so that i can access the property value stored in selected contentpicker page.
Regards, Manisha
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Manisha, Have you tried the first code snippet? Code:umbraco.presentation.nodeFactory.Node n = new umbraco.presentation.nodeFactory.Node(idOfNode) whereas idOfNode is the id of the node from the contentpicker page. In your case, that should be the 'caption' Hope this helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 11/12/2008 Posts: 13 Location: Bombay
|
Hi Dirk,
I got the value for property caption.
Currently the idOfNode is the pageId which holds the caption property. using the getProperty("caption") i could get the value for it.
Thanks for the help
Regards, Manisha
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Bingo! Glad you've found it yourself. Greetz, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
|
Guest |