MyBB Community Forums

Full Version: Noparse
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(EDIT) The below I posted earlier but I have now found a way to make it work but I need to open inc/functions_post.php. I can find this on filezilla but have no idea on how to open it. Can anyone help










Hi

I am extemely sorry if this is somewhere else but I have spent 10 minutes looking and have found nothing.

On my forum I want to create a guide about the BBcodes that run on the site. The thing is, as you already know, when you type a code it will do its job! But I want to be able to show the code and for it not to do its job just for this guide.

Its easy enough to enter the code incorrectly so it wont work just by puting a space in but it doesnt look professional enough for a guide.

On other forums you are able to use the noparse bbcode. This stops another bbcode from doing its job and generally looks like this
[noparse][/noparse]

Heres an example- [noparse]Text here[/noparse]

If the noparse was to work users would see [b]text here[ /b] instaed of the above example (I have put the space in to be able to show it)

Can anybody help? If it is simply a different bbcode to use then that is great. If there is a simple mod installation then that is fine as well but if I have to go into the sites coding and insert things myself I my be stuck as I am not good at that unless it is really simple!

Thanks in advance
(2011-02-21, 11:26 PM)gcrock Wrote: [ -> ](EDIT) The below I posted earlier but I have now found a way to make it work but I need to open inc/functions_post.php. I can find this on filezilla but have no idea on how to open it. Can anyone help

You can open it in any text editor, but I recommend Notepad++.
(2011-02-22, 05:29 AM)Joshua Mayer Wrote: [ -> ]
(2011-02-21, 11:26 PM)gcrock Wrote: [ -> ](EDIT) The below I posted earlier but I have now found a way to make it work but I need to open inc/functions_post.php. I can find this on filezilla but have no idea on how to open it. Can anyone help

You can open it in any text editor, but I recommend Notepad++.

Thank you very much
(2011-02-21, 11:26 PM)gcrock Wrote: [ -> ](EDIT) The below I posted earlier but I have now found a way to make it work but I need to open inc/functions_post.php.

I think the solution comes from an old message . But there (in the read me file of the noparse.phf file that is coped to the /inc/plugins directory) it was said that:

Quote:Open inc/functions_post.php

Before this:

if($allowsmilies != "no")

Add this:

$message = $plugins->run_hooks("pre_parse_message", $message);

close & save.

Go to the AdminCP and enable the plugin.

But when I open the inc/functions_post.php file, I cannot find the if($allowsmilies != "no") statement. And later the read me file sais:

Quote:If you don't modify your inc/functions_post.php file, the plugin won't work,

And indeed, it does not work!!!! Has this something to do with old versions? I am just new here, so I have no experience at all!!

Thanks in advance,

Ad Bakker
(2011-06-04, 07:28 PM)Ad Bakker Wrote: [ -> ]And indeed, it does not work!!!!

Since I did not like the noparsing solution mentioned before anyway, because is involves changes in the source code, I started to try my own solution. Although I have programming experience since 1968, this was only in FORTRAN and related languages. I had never done sometjing in html/php or even C. After studying the source of some programs, and some manual pages on internet I managed to get something to work. This code is:

<?php
/************************************************************
* author       : Ad Bakker
* plugin       : Noparse BBCode
* last_mod     : 06.10.2011 (June 10th 2011)
* version      : 1.0
*************************************************************/
if(!defined('IN_MYBB'))
{
	die("This file cannot be accessed");
}

//
// make sure "noparse_run" is called at the start op the parsing process
//
$plugins->add_hook("parse_message_start", "noparse_run");

function noparse_info () {
	return array (
		"name"		=> "Tag [noparse]",
		"description"	=> "Tag [noparse], MyCode source",
		"author"	=> "Ad Bakker",
		"version"	=> "1.0",
	);
}

function noparse_activate () {
// Activate plugin
// no action required
}

function noparse_deactivate () {
// Deactivate plugin
// no action required
}

function noparse_run ($message) {
//
// In between the [noparse] and [/noparse] tags all square bracket characters
// "[" and "]" are replaced by the Unicode equivalemts &#91 and &#93, respectively.  
// By that they remain their "looks" but BBCode tags are no longer recognized as  
// such by the BBCode parsing process
//
	$match_pattern = '#\[noparse\](.*?)\[/noparse\]#is';
	if (preg_match_all($match_pattern,$message,$matches,PREG_SET_ORDER)) {
		foreach ($matches as $found) {
//
//			remove noparse tags
//
			$replace = preg_replace($match_pattern,"$1",$found[0]);
//
//			replace square brackets by Unicode equivalents
//
			$replace = str_replace(array('[',']'),array('&#91','&#93'),$replace);
//
//                      replace text in between noparse tags by text with converted brackets
//
			$message = preg_replace($match_pattern,$replace,$message,1);
		}
	}
	return $message;
}

?>

Save the above as "noparse.php", copy it to the /inc/plugins folder and activate it in the Plugins Admin control panel, and it works!!
There are still quite som things that I do not understand in php programming, but I learned a lot of it.

Regards,

Ad Bakker
^ oh ! that appears to be brilliant.
if works fine then please make it available thru mods section.

thanks Smile
(2011-06-10, 05:37 PM)ranjani Wrote: [ -> ]please make it available thru mods section.

I've done that now. Again a new experience........ (learning all the time!!)

Please give a reaction when you've tried it.

Regards,

Ad Bakker
(2011-06-10, 05:37 PM)ranjani Wrote: [ -> ]if works fine then please make it available thru mods section.

I have done that, and yesterday i saw it was available. But when I downloaded it it was in error. I suppose something has gone wrong in the validation process.

In the str_replace code line the semicolons (;) after the &#91 and &#93 unicode equivalents for the square brackets [ and ], were removed. The result was that it did not work anymore.
I have submitted a version 1.1 to correct this, but again this has to be validated. I am curious whether this will be done correctly now!!!!

Regards,

Ad Bakker
^ :oops: I forgot about your plug-in. its working now. Thank You.