How to insert a document type propery into the content part of a node?
Hello all,
I've defined a 'phone number' property on a document type.
I'd like to have the user to be able to insert the value of this property into the text he/she is editing in the bodytext of the same page.
I saw how to insert this property into a template, but the user should be able to insert it where ever is appropriate.
I tried with a macro, but that didn't result in any output.
The idea behind this is that whenever a phonenumber needs to be changed, it can be changed on the top node and all the child nodes that use the value (in their editable bodytexts), should recursively use that value.
What was the problem you had when you were doing it via a Macro, that's how I'd do it. I'd have the macro either as an XSLT which just has something like this:
The problem is that the macro is not showing any value.
Another feature is that I want to specify the value of phoneNumber only on the top node and where ever it is referenced, it should recursively retrieve the value.
I was looking for the xslt reference but I can not find it anymore... :(
Could you please provide some examples of your structure and the code you are using now? I think it would be easier to help you out when one can see what you are doing :)
First we need to find out why you are not getting any value from the field in your xslt macro.
It should not be a problem fetching the value recursively - I would think that you can use something like this to do it
Jan and Slace, great stuff, this -=almost=- solved the problem.
Now it is recursively getting the number and the user is able to insert it into the text.
The only thing that remains is that the macro is wrapped in a <div></div> block and that inserting it closes the <p> tag and opens a new one after. This implies that the user needs to go to the html editor to fix this.
Is there a way to not have the macro wrap its output in <div> tags?
but still, the output is inserted in a <div> tag and in the wrong place:
<p><strong>Call us at I INSERTED HERE</strong> to .... some more text</p> <!-- AND THIS IS WHERE IT APPEARED --> <div ismacro="true" umbversionid="7a8b63ff-28a6-44a2-819f-8ee47f3e5567" umbpageid="1103" umb_macroalias="insertPhoneNumber" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div>
hmm ok that part I don't know to much about...I'm not to sure what is going on when you use macros in the RTE. I hope there are some others that can give an answer to that :)
Just tried this on a fresh Umbraco 4.0.2.1 install, what version are you on?
It's true that the inserted macro renders the <div ismacro="true ...> code when checking the code via the HTML button in the editor. But the output in the actual front-end page doesn't contain the html-code. It only renders a <span>content</span> as it should.
Another approach useful for merging data from anywhere into your bodyText. The goal is to be able to use the richtext editor and insert mergefields. The like this:
Hello [memberName],
Your are welcome to contact us on [companyPhoneNumber]
Regards
[companyContact]
To make that work make an xslt extension that finds the mergefields and fetches the data:
On the template you then need to use the extension like this:
@siko279: you don't close topics, you just mark post that was most useful as the answer. It might not be an 'answer' as in 'oh, that post does really solve my problem', it could quite easily be a 'suggestion' that got you on the right track!
How to insert a document type propery into the content part of a node?
Hello all,
I've defined a 'phone number' property on a document type.
I'd like to have the user to be able to insert the value of this property into the text he/she is editing in the bodytext of the same page.
I saw how to insert this property into a template, but the user should be able to insert it where ever is appropriate.
I tried with a macro, but that didn't result in any output.
The idea behind this is that whenever a phonenumber needs to be changed, it can be changed on the top node and all the child nodes that use the value (in their editable bodytexts), should recursively use that value.
Any ideas on how to achieve this?
Thanks
What was the problem you had when you were doing it via a Macro, that's how I'd do it. I'd have the macro either as an XSLT which just has something like this:
(Ok, that should be close, XSLT was never my strong point)
Or you can use the nodeFactory API to get it, using the UmbracoContext.Current.PageId property to constructor so it gets the right one.
The problem is that the macro is not showing any value.
Another feature is that I want to specify the value of phoneNumber only on the top node and where ever it is referenced, it should recursively retrieve the value.
I was looking for the xslt reference but I can not find it anymore... :(
Ok, adding $currentPage makes it render, only if the number is specified on the current page.
Maybe I can 'hard code' the xslt to look on the root node?
Could you please provide some examples of your structure and the code you are using now? I think it would be easier to help you out when one can see what you are doing :)
First we need to find out why you are not getting any value from the field in your xslt macro.
It should not be a problem fetching the value recursively - I would think that you can use something like this to do it
Jan and Slace, great stuff, this -=almost=- solved the problem.
Now it is recursively getting the number and the user is able to insert it into the text.
The only thing that remains is that the macro is wrapped in a <div></div> block and that inserting it closes the <p> tag and opens a new one after. This implies that the user needs to go to the html editor to fix this.
Is there a way to not have the macro wrap its output in <div> tags?
Another problem just discovered: the macro renders it's content and stops being a macro, meaning that next time the value is not looked up anymore.
Maybe I'm just a bit confused.
Here's what I have: Master Doc Type with property: phoneNumber (alias)
Node based on child of the Master Doc Type, but the property is given a node above (root node).
<
<
<
</
sorry about the mess,
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:value-of select="$currentPage/ancestor-or-self::node/data [@alias = 'phoneNumber']"/>
</xsl:template>
To wrap your stuff up in a <div> tag and a <p> tag you just need to put it in your XSLT like this
I want the output to be inside a <span> tag, the macro:
<xsl:template match="/">
<span>
<xsl:value-of select="$currentPage/ancestor-or-self::node/data [@alias = 'phoneNumber']"/>
</span>
</xsl:template>
but still, the output is inserted in a <div> tag and in the wrong place:
<p><strong>Call us at I INSERTED HERE</strong> to .... some more text</p>
<!-- AND THIS IS WHERE IT APPEARED -->
<div ismacro="true" umbversionid="7a8b63ff-28a6-44a2-819f-8ee47f3e5567" umbpageid="1103" umb_macroalias="insertPhoneNumber" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div>
hmm ok that part I don't know to much about...I'm not to sure what is going on when you use macros in the RTE. I hope there are some others that can give an answer to that :)
Just tried this on a fresh Umbraco 4.0.2.1 install, what version are you on?
It's true that the inserted macro renders the <div ismacro="true ...> code when checking the code via the HTML button in the editor. But the output in the actual front-end page doesn't contain the html-code. It only renders a <span>content</span> as it should.
Regards
.Hauge
This is because you can't have a <div> tag inside a <p> tag in strict XHTML.
I had similar problems with trying to insert HTML "snippets" with macros.
I never really found a satisfying solution.
I believe that you can program your own extension to TinyMCE, i looked at it, but havent had the time to do it yet.
I'm using version 4.0.2.1 ...
With some editing, (putting the div tag inside the p tag, which is not optimal), the phonenumber is displayed.
So I have to join Mikael and be at least a bit unsatisfied with the solution as-is ... but this topic is solved!
Thanks to all for contributing.
How can I close this topic?
Another approach useful for merging data from anywhere into your bodyText. The goal is to be able to use the richtext editor and insert mergefields. The like this:
Hello [memberName],
Your are welcome to contact us on [companyPhoneNumber]
Regards
[companyContact]
To make that work make an xslt extension that finds the mergefields and fetches the data:
On the template you then need to use the extension like this:
/Jesper
@siko279: you don't close topics, you just mark post that was most useful as the answer. It might not be an 'answer' as in 'oh, that post does really solve my problem', it could quite easily be a 'suggestion' that got you on the right track!
Cheers,
Dirk
@jesper ordrup: Thanks for that... good suggestion.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.