问题
I'm building a website for a voluntary group to support dyslexia-related learning difficulties and one of their aids is to change the text from plain black and white to multi-coloured, so that every nth character for example, the colour changes to a contrasting one.
An example can be seen at: Colorise plugin
[colorize] To change any text from plain to colorised, I have to edit the article and add the html tags like so. [/colorize] (I know the brackets are wrong.)
To change back to plain, I have remove the tags and save again - which is all done in the admin back end.
What I need to do, is add some sort of button to the front of the site with a label to inform visitors they can change the text from plain to coloured and vice versa.
This is because not all visitors to this site will be able to read this multi-coloured text, so it needs to be setup in an on/off way.
If anyone can help with this I would very much appreciate it.
From my limited understanding, it's a matter of pointing an HMTL button at the joomla colorise plugin, which I think is fairly straight forward for the right individual maybe?
回答1:
You can achieve this by slightly modifying the plugin to listen to something from the button. In order to do this you should open the plugins>content>colorize>colorize.php
and enclose lines 52 to 390 inside this if:
if(JFactory::getApplication()->input->get('addmulti', 0, 'int') == 1){
...
lines 52 through 390
...
}
That way you don't have to remove the {colorize}{/colorize} tags to avoid multicolor text as the plugin will only show colorized text when the link has this:
&addmulti=1
for example the link should look like this:
/index.php?option=com_content&view=article&id=1&addmulti=1
without the above in the link the plugin won't render the colorized text. You can then create a button that will append &addmulti=1 to your url and reload the page for those who want the colored text.
Finally the text in your article would be like this:
{colorize}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse pharetra commodo elit, quis elementum mi dignissim quis. Donec varius semper nisi. Cras auctor quam nec elit auctor mattis. Etiam lobortis tempus mi, ac blandit tortor mattis eget. Proin ipsum ligula, aliquam sit amet mollis non, pulvinar eget ipsum. Quisque consectetur dui nec metus laoreet rhoncus. Duis a viverra turpis. Vestibulum id tortor semper, sollicitudin felis id, elementum justo. {/colorize}
来源:https://stackoverflow.com/questions/20843423/need-to-control-a-plugin-from-front-end-to-apply-to-article-text-only-is-this