Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Bbcodes in news textarea

@Chan
Greetings cordially !!
We have worked in the past to add bbcod "code" in the news-textarea.
Now in the version Andromeda 9.03.50 the addition of "code" in the comments in the section NEWS and BLOG works perfectly.
However, the problem is in the news editor - textarea. There is no link to "code". So you cannot add the source code in the original to the text of the article.
The problem will probably be here:
Filename: html_buttons_include.php
| Author: PHP-Fusion Development Team
*******
CodeDownload  

$res = "";
 if ($html) {
 $res .= "<div class='btn-group'>\n";
 $res .= "<button type='button' value='b' title='".$locale['html_000']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<b>', '</b>', '".$formname."');\"><i class='fa fa-bold'></i></button>\n";
 $res .= "<button type='button' value='i' title='".$locale['html_001']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<i>', '</i>', '".$formname."');\"><i class='fa fa-italic'></i></button>\n";
 $res .= "<button type='button' value='u' title='".$locale['html_002']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<u>', '</u>', '".$formname."');\"><i class='fa fa-underline'></i></button>\n";
 $res .= "<button type='button' value='strike' title='".$locale['html_003']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<del>', '</del>', '".$formname."');\"><i class='fa fa-strikethrough'></i></button>\n";
 $res .= "<button type='button' value='blockquote' title='".$locale['html_004']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<blockquote>', '</blockquote>', '".$formname."');\"><i class='fa fa-quote-right'></i></button>\n";
 $res .= "<button type='button' value='hr' title='".$locale['html_005']."' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<hr/>', '', '".$formname."');\"><i class='fa fa-arrows-alt-h'></i></button>\n";
 $res .= "</div>\n";



I guess the link to is missing
CodeDownload  
$res .= "<button type='button' value='??????????' title='".$locale['???????????']."'


Possible solutions, add???
CodeDownload  
$locale['html_021'] = "code";


Would you have a solution, please?
Kvido attached the following image:
bbcode_in_comments_blog.png bbcode_in_news_editor2.png
Good idea, can you wait for commit? We will inform you when it's there.
Yes, thanks I'll wait
The code works by adding:
CodeDownload  
<pre><code>code<code> </pre>

I'm almost done:
CodeDownload  

$res .= "<button type='button' class='btn btn-default btn-sm button m-b-10' value='code' title='".$locale['html_021']."' onclick=\"insertText('".$textarea."', '<pre><code/><code></pre>', '".$formname."');\"></button>\n";


CodeDownload  


A better solution would be to add:
src = "/ includes / bbcodes / images / code.svg

Quote

I'm almost done:
CodeDownload  

$res .= "<button type='button' class='btn btn-default btn-sm button m-b-10' value='code' title='".$locale['html_021']."' onclick=\"insertText('".$textarea."', '<pre><code/><code></pre>', '".$formname."');\"></button>\n";


It remains to change the button in the textarea editor


You know I tried this out and it doesn't quite work as is, until I made a couple of changes thusly:
CodeDownload  
$res .= "<button type='button' class='btn btn-default btn-sm button m-b-10' value='code' title='".$locale['html_021']."' onclick=\"insertText('".$textarea."', '&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;', '".$formname."');\">&lt;/&gt;</button>\n";



You had the 'code and end code' backwards; also I removed the 'br' at the end of the line.
Thanks for your interest.
The "code" button did not appear for your edit. My button is a little bad.
The best solution so far is here:
https://nekecamweb.cz/news/10/Test-in...insert-kod
CodeDownload  

$res .= "<button type='button' class='btn btn-default btn-sm button m-b-10' value='code' title='".$locale['html_021']."' onclick=\"insertText('".$textarea."', '<pre><code></code></pre>', '".$formname."');\">< / ></button>\n";


A better solution would be to add:
src = "/ includes / bbcodes / images / code.svg
So far, the solution code is a replacement. We'll see what Chan says
Kvido attached the following image:
bbcode_in_news_editor2_1.png
That's all.
CodeDownload  
$res .= "<button type='button' value='code' title='code' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '&lt;pre&gt;&lt;code&gt;', '&lt;/code&gt;&lt;/pre&gt;', '".$formname."');\"><i class='fa fa-code'></i></button>\n";

@RobiNN
Your adjustment is easier and better.
In both edits, however, the source code snippet (for such a complex one) is not complete!
https://nekecamweb.cz/news/11/test2

There is no problem with the settings here:

CodeDownload  

/**
 * Format spaces and tabs in code bb tags
 *
 * @param string $text
 *
 * @return string
 */
function formatcode($text) {
 $text = str_replace(
 [" ", " ", "\t"],
 ["&nbsp; ", " &nbsp;", "&nbsp; &nbsp;"],
 $text
 );
 $text = preg_replace("/^ {1}/m", "&nbsp;", $text);

 return $text;
}

Kvido attached the following image:
bbcode_news_editor2.png
Finally had some time to look into things, and this is my input for the button.

CodeDownload  
$res .= "<button type='button' value='code' title='Format as Code' data-toggle='tooltip' class='btn btn-sm btn-default m-b-10 button' onclick=\"addText('".$textarea."', '<code>', '</code>', '".$formname."');\"><i class='far fa-code'></i></button>\n";



I do not know how you stored the code, maybe you have some entity problem. But according to your link, and a quick test file shown no errors.

I attached a file here test. Open up the file in the browser containing the testbox.

Everything is pretty standard here. I didn't need to alter anything in core except adding a html button.
Chan attached the following file:
code-html.zip [536Bytes / 20 Downloads]
Kvido attached the following image:
bbcode_in_news_editor3.png
I tried the code that Chan published. Everything works for me.
Only the output of the icon needs to be corrected, there is a typo. Remove the letter r from class = far fa-code.
Before you copy the code from the forum, I recommend disabling the page translation if you use a translator.

If this does not help, try replacing the html_buttons_include file with a new one and paste the button code into it.
Clear your browser cache. Simple tips for an experiment in search of errors.
zizub attached the following image:
0001a.jpg 0001.jpg
@Z:
1 / Thanks for the typo "r"
2 / Cache etc. OK!
3 / The result of the code is still incomplete
4 / What version are you using, I have Andromeda 9.03.50
Wait for new release (9.03.60).
That would be best. Thanks!

Quote

4 / What version are you using, I have Andromeda 9.03.50

I tried the button code in Andromeda 9.03.50
Thread Information
Author
Replies
16 posts
Views
460 times
Last Post
Last updated on 4 months ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Kvido, Chan, Grimloch, zizub, RobiNN