This has been a real bug-bear of mine for over a year and I'm willing to transfer £100 (via paypal) to someone for a positive solution...
Here's the task...
We have many sites where we utilies code snippets ranging from things like company_name,company_postcode to advert boxes or touts that are resused on multiple content pages. Now, ... we want to encourage our clients to re-use these snippets wherever possible as hard-coding such things as company_tel can be a real drag if it changes.
We pull these snippets into the TinyMCE Conent editor via various MACROs. This part works really well and is a flexible solution (although I'm willing for someone to pipe up with an alternative)...
.....but there's a problem!
Whenever these MACROs are pulled into the content editor they are always within a DIV element. This is a problem for a couple of reasons:
1./ TinyMCE wants to put P elements pre and post the DIV (as a DIV cannot exist inside a P element). 2./ TinyMCE outputs these MACRO's as block level elements which is a real drag if the macro is a snippet to repace a 10 character string.
QUESTION 1 >> So,... I think that the best solution would be to make Umbraco render MACROs within the SPAN element rather than the DIV element. Is this possible and if so how?
QUESTION 2 >> I can't beleive that nobody else is having this issue. There are such clever people on this forum, which leads me to beleive there is a better way of carrying out what I am aiming for - can anyone advise?
Anyway - I'll leave this £100 prize open to anyone who can come up with a solution, Many thanks in advance,
You may want to look at enabling the templates feature of TinyMCE, to allow you to drop in predefined snippets of code. You could then have the templates insert the predfined snippet keywords therfore not needing to rely on the user to type them correctly, then just replace the flags via an event handler.
Take a look at this article on how to enable the templates menu in umbraco 4
Firstly, thank you for the really fast and thoughtful reply.
We have looked into this in the past and were very unconfident of heading down this direction for the following reasons:
We couldn't find a way of making TinyMCE templates to pull through user definable values (e.g. properties on a document)
Ultimately we felt that it was highly likely that the templating feature may become unsoprted in future versions of Umbraco
Please let me know if I am mistaken regarding my feedback above :-)
I really do think Umbraco is great, and I'm sure that there must be a solution/direction that the Umbraco framework itself wants me to code in. Is it just us that wants to reuse little snippets of code and dynamic variables?
I think many of us have struggled with the fact that macros int TinyMCE will always be a block element, so you are definitely not the only one. But is has been this way always, and I think that is why there is not many posts on the subject, because we have just accepted that it's just the way it is.
However, it would be nice to be able to solve this somehow. Put it on codeplex as a feature request (if it is not there already). It's got my vote.
Not sure this will work as, again, I'm not sure that there will be an opportunity for Umbraco to pass the snippet and insert the dynamic code. I hope I'm wrong and that it would be possible for someone to code this package for me as I'd happily pay.
Until thien, we'll just have to continue to use our current solution (which is not great)....
... essentially we insert the Umbraco Macros and then revisit the HTML and add a class which equates to "display:none;" on the undesirable P elements :'(.
Don't you just hate bodging applications to get them to play the game?
If you created a custom button, you could get it to do whatever you want. Something like launch a dialog which retrieves the list of allowed fields, which you then select one, and it inserts it into the RTE.
I'm not saying it would be easy =) but if you want it integrated, I would say thats your best bet. I'd be happy to look at it, unfortunatley I've already got a backlog of packages to get through =)
Snippets, Macros and TinyMCE = Hell
Hi everyone,
This has been a real bug-bear of mine for over a year and I'm willing to transfer £100 (via paypal) to someone for a positive solution...
Here's the task...
We have many sites where we utilies code snippets ranging from things like company_name,company_postcode to advert boxes or touts that are resused on multiple content pages. Now, ... we want to encourage our clients to re-use these snippets wherever possible as hard-coding such things as company_tel can be a real drag if it changes.
We pull these snippets into the TinyMCE Conent editor via various MACROs. This part works really well and is a flexible solution (although I'm willing for someone to pipe up with an alternative)...
.....but there's a problem!
Whenever these MACROs are pulled into the content editor they are always within a DIV element. This is a problem for a couple of reasons:
1./ TinyMCE wants to put P elements pre and post the DIV (as a DIV cannot exist inside a P element).
2./ TinyMCE outputs these MACRO's as block level elements which is a real drag if the macro is a snippet to repace a 10 character string.
QUESTION 1 >>
So,... I think that the best solution would be to make Umbraco render MACROs within the SPAN element rather than the DIV element. Is this possible and if so how?
QUESTION 2 >>
I can't beleive that nobody else is having this issue. There are such clever people on this forum, which leads me to beleive there is a better way of carrying out what I am aiming for - can anyone advise?
Anyway - I'll leave this £100 prize open to anyone who can come up with a solution,
Many thanks in advance,
David :)
Hi David,
You may want to look at enabling the templates feature of TinyMCE, to allow you to drop in predefined snippets of code. You could then have the templates insert the predfined snippet keywords therfore not needing to rely on the user to type them correctly, then just replace the flags via an event handler.
Take a look at this article on how to enable the templates menu in umbraco 4
http://our.umbraco.org/wiki/how-tos/enabling-the-'template'-plugin-for-tinymce
Many thanks
Matt
Hi Matt,
Firstly, thank you for the really fast and thoughtful reply.
We have looked into this in the past and were very unconfident of heading down this direction for the following reasons:
Please let me know if I am mistaken regarding my feedback above :-)
I really do think Umbraco is great, and I'm sure that there must be a solution/direction that the Umbraco framework itself wants me to code in. Is it just us that wants to reuse little snippets of code and dynamic variables?
Kind regards,
David
I think many of us have struggled with the fact that macros int TinyMCE will always be a block element, so you are definitely not the only one. But is has been this way always, and I think that is why there is not many posts on the subject, because we have just accepted that it's just the way it is.
However, it would be nice to be able to solve this somehow. Put it on codeplex as a feature request (if it is not there already). It's got my vote.
You could add a custom button and program the rest yourself? This doesn't seem the easiest thing to do though, but others have managed it:
http://our.umbraco.org/forum/developers/extending-umbraco/7873-Custom-button-in-TinyMCE
Matt
Hi Matt,
Not sure this will work as, again, I'm not sure that there will be an opportunity for Umbraco to pass the snippet and insert the dynamic code.
I hope I'm wrong and that it would be possible for someone to code this package for me as I'd happily pay.
Until thien, we'll just have to continue to use our current solution (which is not great)....
... essentially we insert the Umbraco Macros and then revisit the HTML and add a class which equates to "display:none;" on the undesirable P elements :'(.
Don't you just hate bodging applications to get them to play the game?
Kind regards,
David
If you created a custom button, you could get it to do whatever you want. Something like launch a dialog which retrieves the list of allowed fields, which you then select one, and it inserts it into the RTE.
I'm not saying it would be easy =) but if you want it integrated, I would say thats your best bet. I'd be happy to look at it, unfortunatley I've already got a backlog of packages to get through =)
Matt
Hi Matt,
Thanks for getting back to me.
If I exchange details with you would you consider taking on this task for me at a later stage? (paid of course).
Kind regards,
David
If nobody else comes back before I have some free time, then yea, I'd be happy to take a look at it.
Checkout my profile page for my contact details (web/twitter)
Matt
is working on a reply...