Extension talk:ToggleDisplay2

From mediawiki.org
Jump to navigation Jump to search

MediaWiki 1.16.1 -Does not work for me[edit]

I have tested both versions of this extension but it doesn't show any text between the two tags, see

Source

text before 
<toggledisplay status="hide" showtext="showdetails" hidetext="hide details">
  hidable text
</toggledisplay>
text after

Are the some other extensions which have to be installed or some php parameters to be set ?

My System configuration:

Produkt 	Version
MediaWiki 	1.16.1
PHP 	        5.3.2-1ubuntu4.7 (apache2handler)
MySQL 	        5.1.41-3ubuntu12.7

Thanks for help, greets, michael. --82.136.114.78 10:39, 22 January 2011 (UTC)[reply]

Hi Michael, no this extension does not require any other extensions or php parameters to be set. Your example source works fine in my two 1.16.0 wikis. I do not have access to a 1.16.1 Wiki, I also have different (older) PHP and MySQL versions (although I don't think that's the problem). You might want to check the Special:Version page of your wiki to check if this extension was installed successfully (and check if the <toggledisplay> tag is listed in the Parser extension tags section). If it's not, please check if your LocalSettings.php contains the require_once( "extensions/ToggleDisplay/ToggleDisplay2.php" ); line and whether the extension php file is really located at that path. Hope this helps. --Roberthaenel 00:13, 23 January 2011 (UTC)[reply]
Hi there, I have exactly the same problem. Install all went OK and the text between the tags is hidden as expected. However, there is no [show details] link to click and make the text appear. After reading this post I rolled back from 1.16.1 to 1.16.0 but it made no difference. Re the questions above, the extension is listed on the version page, and the tag is listed there also. I am running PHP 5.3.5 and MySQL 5.5.8. Maybe it is a PHP issue? Any help or suggestions would be appreciated. Thanks, Mark. Mark
Hi again. I did not realise you were the author, Robert, until I went back to this page. Thanks for a great extension, I can't wait to get it going!! Mark.
Hi, I have installed a test server with PHP 5.2.3 and MySQL 5.0.41 and the extension works correctly. It is looking more like a PHP issue now. Any thoughts Robert? Thanks, Mark.
Hi Mark, yes it looks indeed like this issue might be related to PHP 5.3, but I also found an issue with the source code I posted here (somehow an extra line break was inserted when I pasted the code, which messed up the HTML output of the extension). This is fixed now. In fact, I rewrote the part where the HTML is generated. Although I don't think that this was related to your problem, you might want to try to use the updated code.
If it's still not working for you, please check the page source (CTRL + U in Firefox). For me Michael's example (see above) produces the following HTML:
...
<p>text before</p>
<a id='toggledisplay1l' href='javascript:toggleDisplay( "toggledisplay1", "hide details", "showdetails" )' style='font-size:smaller'>showdetails</a>
<div id="toggledisplay1" style="display:none;">
<pre> hidable text </pre>
</div>
<p>text after</p>
...
Please compare to your output and let me know which part exactly is missing. In the mean time I will try to get access to a wiki with PHP 5.3... --Roberthaenel 04:19, 24 January 2011 (UTC)[reply]
Hi and thanks for the quick response! I have updated your code and still have the same problem, with the link not showing, on PHP 5.3. The PHP is not inserting any of the '$result' string at all into the HTML output. Below is the page source for me. (BTW, the javascript function is in the source listing OK a bit further up the page).
The easiest way to test it on PHP 5.3 might be to download a portable setup, such as the latest Uniform Server (if using Windows). It will just run from the downloaded folder after a quick configuration. Then just pop a clean copy of MediaWiki in the WWW folder, a quick config of that and you will be up and running! This is what I did to test PHP 5.2 - I downloaded an old version of Uniform Server. Mark.
...
<p>text before 
</p><p>text after
</p>
...
Hi, the issue is fixed now. The problem was the function that does the rendering not being called, because it seems that passing variables by reference with a & is not supported anymore with PHP 5.3. After removing the & it works fine with my PHP 5.3.2 as well as older 5.x setups. Thanks for all your suggestions in localizing the problem. --Roberthaenel 12:18, 25 January 2011 (UTC)[reply]
Hi. All fixed!! Thanks for your help! Mark.

Possible Layout Change[edit]

Would it be easy to modify this to display the [Show Less] link after the text that is expanded?

I would like it to emulate the '...more' and '...less' notations often used in blogs. After the text is expanded with the '...more' link, I would like the '...less' link to appear at the end of the expanded text.

Thanks, Mark.

Hi Mark, yes, that quite simple: please look for the following line in the code (this is where the show/hide link is generated):
$result .= <<<EOD
<a id='$linkid' href='javascript:toggleDisplay( "$id", "$hidetext", "$showtext" )' style='$linkstyle'>$linktext</a>
EOD;
... and then just cut and paste it three lines below (after the $result .= '</div>'; line). Maybe I will add an option later to switch between this and the default behavior. --Roberthaenel 04:24, 24 January 2011 (UTC)[reply]
Thanks. I had been playing around and worked out something similar so all good. Mark.
Top, Bottom or BOTH would be nice...long text areas would benefit from the top & bottom links for the 'Show Less' state.--GillianBates 14 August 2011

Change Tags[edit]

I am not sure how tags are allocated in MediaWiki and what stops several extensions using the same tag, with obvious conflicts! Anyway, if there is no control over the tags in general, is it possible to change the tags used with ToggleDisplay? For example, it is easier to type (and remember) '<Hide>' than '<Toggledisplay>' in an article. I found where this can be changed in

$parser->setHook( 'ToggleDisplay' , 'efToggleDisplayRender' );

but wonder if this is allowed, and whether it could it be stored in the array at the start of the code? Mark.

I currently do not plan to rename the tag, because I want this extension to be backward compatible with the original ToggleDisplay extension and don't want users that are migrating to ToggleDisplay2 to have to change all their pages where the tag appeared. However, you are of course free to change the tag name in your wiki as you wish: just change the line you already found to, for example:
$parser->setHook( 'hide', 'efToggleDisplayRender' );
That's all that is required to be able to use '<hide>' instead of '<toggledisplay'>. --Roberthaenel 12:37, 25 January 2011 (UTC)[reply]

Is it possible to use Internationalized messages for Show and Hide details[edit]

Robert,

Thanks for this very nice extension, which makes it easy to hide lengthy portions of text in an article. I can't refer you to a wiki where I have it running yet, since our beta test is behind a .htaccess password prompt, which I don't want to post in a forum.

However, I am wondering what would be involved in making the

                'showtext' => '[show details]',
                'hidetext' => '[hide details]',

display in the language used by the logged in user? Our wiki supports, English, French, German, and Spanish using the Languages template. In other words, how would I define it as a message that could be overridden in the Special:AllMessages for when the pages are displayed in French, German, or Spanish.

By the way, I preferred to display the Hide details after the text, so I edited the code based on a previous response on this talk page, so that would certainly be a nice option to set.

Thanks in Advanced. --Ken Roy 18:37, 25 March 2011 (UTC)[reply]

Using the additional parameter syntax, a page written in French could use the following
<toggledisplay status="hide" showtext="montrez les détails" hidetext="cachez les détails">
so it may not be necessary to create the ToggleDisplay2.i18n.php file.
Robert, thanks again for this extension. It is a lot nicer than using collapsible and collapsed tables, just to collapse text sections of a page that would normally not be in a table. --Ken Roy 11:49, 27 March 2011 (UTC)[reply]

Substituting Images for the Show More and Hide More text[edit]

Greetings Robert...thank you for the simple, useful and effective extension. I would love to see a feature that allows a pair of Images to be used in place of the text links. Users do love their icon buttons :-)

Is this something that might be easily and cleanly added to this extension? --GillianBates 14 August 2011

Interoperability with Rich text editor[edit]

Hello,

Thank you for the extension!

What can I do to make the extension works better with rich text editors? (I tried FCKEditor and WYSIWYG 1.5.6 extensions) the original text is <toggledisplay>toggledisplay box</toggledisplay>

the resulting saved page is: [[Javascript:javascript:toggleDisplay( "toggledisplay1", "[show]", "[show]" )|[show]]]

the Jspoiler extension for example does not seem to do this (it is marked as <Special> by the editor but it is not changed)

Is there a way to achieve this with ToggleDisplay?

Nested Expansions[edit]

Hey, I just got the extension implemented and was wondering if anyone knew of a way to nest some [nowiki]<toggledisplay> [/nowiki] tags within others such that there would be two main headings on a page with a line under each that said "click to expand" and then within each there was another list of "Click to view _______" buttons all using toggledisplay?

Ex.

Click to expand 1 open

Click to view 1
Click to view 2
Click to view 3

Click to expand 1 close

Click to expand 2 open

Click to view 4
Click to view 5

Click to expand 2 close

Currently the Click to expand 1 open is interacting with the Click to view 1 close tag. I have tried using tables to stop the tags from interacting but it does not change the outcome. Any other suggestions or solutions.