Problem:
I need to pass a url of a content item to a .net control.
My not-working solution:
* create control with public property
* create macro with parameter (url, string)
* create document type
* add content picker to document type (urlID)
* create template
* add macro to template
* give urlID to macro parameter
now the problem is the urlID should be parsed to the url using umbraco.library:NiceUrl()
Not-working code:
Is it possible to convert the urlID in the template?
I know I could do it in the code of the control as well, but I need an other way now.
Can a library function be used inside a template like I try to do?
You CAN use simple library calls in a template using the xslt feature of the umbraco:Item tag.
Here's how to do it...
First, we'll just display the id to be sure it is being picked up properly. Then we'll add a bit of inline xslt to give us the nice url. To do this, put the following in your template (assuming the urlID is the docType property):
[code][/code]
The easy way to do this is to use the button on the toolbar when you're editing a template. Then you just select the field and you've got the umbraco:Item tag.
When you view your website you should see the id displayed.
Once you've got the id, we'll just add a bit of inline xslt (see this umbraco book for more details: [url]http://umbraco.org/documentation/books/inline-xslt[/url])
[code][/code]
Basically, it applies the xslt command and uses whatever is in the field="" and puts it into the xslt at the {0} placeholder.
Using functions in macro parameters
Problem:
I need to pass a url of a content item to a .net control.
My not-working solution:
* create control with public property
* create macro with parameter (url, string)
* create document type
* add content picker to document type (urlID)
* create template
* add macro to template
* give urlID to macro parameter
now the problem is the urlID should be parsed to the url using umbraco.library:NiceUrl()
Not-working code:
Is it possible to convert the urlID in the template?
I know I could do it in the code of the control as well, but I need an other way now.
Can a library function be used inside a template like I try to do?
You CAN use simple library calls in a template using the xslt feature of the umbraco:Item tag.
Here's how to do it...
First, we'll just display the id to be sure it is being picked up properly. Then we'll add a bit of inline xslt to give us the nice url. To do this, put the following in your template (assuming the urlID is the docType property):
[code][/code]
The easy way to do this is to use the button on the toolbar when you're editing a template. Then you just select the field and you've got the umbraco:Item tag.
When you view your website you should see the id displayed.
Once you've got the id, we'll just add a bit of inline xslt (see this umbraco book for more details: [url]http://umbraco.org/documentation/books/inline-xslt[/url])
[code][/code]
Basically, it applies the xslt command and uses whatever is in the field="" and puts it into the xslt at the {0} placeholder.
Hope that helps.
cheers,
doug.
First of all a big thanks. I got it to work this far.
The second and final problem I now have is that I need to insert this formatted item value in the macro of my user control.
[code][/code]
Generates the correct output and should now be linked to the url parameter of the macro.
[code]
[/code]
Once again thanks for the help so far. Greetings
Bert
[code][/code]
using library functions impossible as a parameter value for a macro inside a template?
Was this ever figured out? I'm having the same trouble trying to insert a URL (from Content Picker ID) into a Macro property.
Same issue here (i posted my thread here: passing a mediaitemurl to a macro as parameter (in a masterpage) - UI Questions - our.umbraco.org ) is there a solution at hand?
I was able to do something like this using:
I think the problem above might have been
Notice "#urlID" doesn't have a closing bracket "]" though I'm not sure if that's it because I wasn't doing exactly the same thing.
is working on a reply...