- Posts: 1
- Thank you received: 0
Kunena 6.3.0 released
The Kunena team has announce the arrival of Kunena 6.3.0 [K 6.3.0] in stable which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x/5.1.x. This version addresses most of the issues that were discovered in K 6.2 and issues discovered during the last development stages of K 6.3
Question [spoiler=título]texto[/spoiler] - Casi conseguido
14 years 7 months ago - 14 years 7 months ago #1
by Jhin
[spoiler=título]texto[/spoiler] - Casi conseguido was created by Jhin
¡¡Buenos días a todos!!
Estoy intentando hacer un spoiler parecido a los que existen en IPB y VBulletin, que consiste en lo siguiente:
SPOILER: título
Texto a ocultar
El caso es que el título funciona correctamente cuando es una sola palabra o número, pero cuando son más, solo muestra la primera. ¿Alguien sabe porque ocurre esto? Creoq ue tiene algo que ver con la variable "default", pero no se como cambiarla para que pille más de una palabra. Si alguien me pudiera ayudar, se lo agradecería mucho.
Os adjunto el código que parsea la tag
Estoy intentando hacer un spoiler parecido a los que existen en IPB y VBulletin, que consiste en lo siguiente:
Code:
[spoiler=título]texto a ocultar[/spoiler]
SPOILER: título
Texto a ocultar
El caso es que el título funciona correctamente cuando es una sola palabra o número, pero cuando son más, solo muestra la primera. ¿Alguien sabe porque ocurre esto? Creoq ue tiene algo que ver con la variable "default", pero no se como cambiarla para que pille más de una palabra. Si alguien me pudiera ayudar, se lo agradecería mucho.
Os adjunto el código que parsea la tag
Warning: Spoiler!
en components/com_kunena/lib/kunena.parser.php
(Sobre la línea 616)
Nota: Si lo usas en tu foro, asegurate de cambiar el nombre de la clase div en la linea: <span class='alert'>. Cambia "alert" por el nombre de la clase deseada.
Otra Nota: El código está muy sucio, hay que limpiarlo. Si consigo solucionar el problema, lo haré, si no, dejaré el código original.
Saludos, Jhin.
(Sobre la línea 616)
Code:
case 'spoiler':
$tempstr = $tag->options['default'];
if($between) {
if ($this->spoilerid==0)
{
// Only need the script for the first spoiler we find
$tag_new = '<script language = "JavaScript" type = "text/javascript">'.
'function fb_showDetail(srcElement) {'.
'var targetID, srcElement, targetElement, imgElementID, imgElement;'.
'targetID = srcElement.id + "_details";'.
'imgElementID = srcElement.id + "_img";'.
'targetElement = document.getElementById(targetID);'.
'imgElement = document.getElementById(imgElementID);'.
'if (targetElement.style.display == "none") {'.
'targetElement.style.display = "";'.
'imgElement.src = "";'.
'} else {'.
'targetElement.style.display = "none";'.
'imgElement.src = "";'.
'}} </script>';
}
else
{
$tag_new = '';
}
$this->spoilerid++;
$randomid = rand();
$tag_new .= '<div id="'.$randomid.'" onClick="javascript:fb_showDetail(this);" style="cursor:pointer;"><img id="'.$randomid.'_img"'.
'src="" border="">'.
(isset($tag->options["title"]) ? ($tag->options["title"]) : ("<span class='alert'><b>SPOILER: </b>".htmlspecialchars($tempstr, ENT_QUOTES)."</span>"))
. '</strong></div><div id="'. $randomid . '_details" style="display:None;"><span class="fb_quote">' . $between . '</span></div>';
return TAGPARSER_RET_REPLACED;
}
return TAGPARSER_RET_NOTHING;
break;
default:
break;
}
return TAGPARSER_RET_NOTHING;
}
Nota: Si lo usas en tu foro, asegurate de cambiar el nombre de la clase div en la linea: <span class='alert'>. Cambia "alert" por el nombre de la clase deseada.
Otra Nota: El código está muy sucio, hay que limpiarlo. Si consigo solucionar el problema, lo haré, si no, dejaré el código original.
Saludos, Jhin.
Last edit: 14 years 7 months ago by Jhin.
Please Log in or Create an account to join the conversation.
14 years 7 months ago - 14 years 7 months ago #2
by JoniJnm
Replied by JoniJnm on topic Re: [spoiler=título]texto[/spoiler] - Casi conseguido
No he mirado ni probado el código, pero a ver si te ayuda esto:
El defaut: break; sólo se pone una vez por todos los cases, es decir:
Si $var no vale ni a, ni b ni c hace lo de default, osea que tu código quedaría así
Pero el default break ya estará en el kunena.parser.php, así que sólo tendrás que añadir el case spoiler (o mejor, modificar el que hay)
El defaut: break; sólo se pone una vez por todos los cases, es decir:
Code:
switch ($var) {
case 'a':
//cosas para hacer si $var vale a
break;
case 'c':
//cosas para hacer si $var vale b
break;
case 'b':
//cosas para hacer si $var vale c
break;
default
//cosas para hacer si $var no vale ninguno de las anteriores
break;
}
Code:
case 'spoiler':
$tempstr = $tag->options['default'];
if($between) {
if ($this->spoilerid==0) {
// Only need the script for the first spoiler we find
$tag_new = '<script language = "JavaScript" type = "text/javascript">'.
'function fb_showDetail(srcElement) {'.
'var targetID, srcElement, targetElement, imgElementID, imgE lement;'.
'targetID = srcElement.id + "_details";'.
'imgElementID = srcElement.id + "_img";'.
'targetElement = document.getElementById(targetID);'.
'imgElement = document.getElementById(imgElementID);'.
'if (targetElement.style.display == "none") {'.
'targetElement.style.display = "";'.
'imgElement.src = "";'.
'} else {'.
'targetElement.style.display = "none";'.
'imgElement.src = "";'.
'}}
</script>';
}
else {
$tag_new = '';
}
$this->spoilerid++;
$randomid = rand();
$tag_new .= '<div id="'.$randomid.'" onClick="java script:fb_showDetail(this);" style="cursor:pointer; "><img id="'.$randomid.'_img"'.
'src="" border="">'.
(isset($tag->options["title"]) ? ($tag- >options["title"]) : ("<span class='alert'><b>SPOILER: </ b>".htmlspecialchars($tempstr, ENT_QUOTES)."</span>"))
. '</strong></div><div id="'. $randomid . '_details" style="display: None;"><span class="fb_quote">' . $between . '</span></div>';
return TAGPARSER_RET_REPLACED;
}
return TAGPARSER_RET_NOTHING;
break;
default:
break;
Last edit: 14 years 7 months ago by JoniJnm.
Please Log in or Create an account to join the conversation.
Moderators: ssh
Time to create page: 0.500 seconds