PDA

View Full Version : [MOD] bbcode in description



StewardManscat
01-06-2005, 12:58 PM
No formatting in the description?

Not sure why this isn't in the product. Suspect there is more to it than I know about. I have put these two hacks in place now, and they appear to be working. Anyone want to raise some alarm bells I'd appreciate it.

In browselinks.php


// dsmhackbegin
require_once('./includes/functions_bbcodeparse.php');
// dsmhackend

while ($links = $DB_site->fetch_array($getlinks))
{
// dsmhackbegin
$links['description'] = parse_bbcode2($links['description'], false,true,true,true);
// dsmhackend
...


In showlink.php


$link['dateadded'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['timeadded'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['keywords'] = stripslashes($link['keywords']);

// dsmhackbegin
require_once('./includes/functions_bbcodeparse.php');
$link['description'] = parse_bbcode2($link['description'], false,true,true,true);

// dsmhackend




The additional args for parse_bbcode2 are hard-coded for my site/preferences (ie disallow HTML). Others may need to tweak further. Contents may settle during shipping. Batteries not included.

Torqued
01-19-2005, 02:55 PM
Brian or Zachary:

Would you guys comment on this mod? BBCODE in the description would be awesome for some things I want to do w/ the Links Directory?

Our Sponsors
 

Brian
01-19-2005, 04:33 PM
Shouldn't be any reason why adding this would be a problem.

Torqued
01-24-2005, 10:06 AM
How would you get this to work for search.php?do=searchresults ??

Our Sponsors
 

Torqued
01-24-2005, 03:05 PM
How would you get this to work for search.php?do=searchresults ??

Responding to myself here..

Have a look at http://www.informaticsnurse.com/links/

and look at the last few links added w/ BBCode in the description.

And then search the links for "SCHIN" - and you'll get some of the same links w/ bbcode..

How can I get those displays to parse the BBCode as well?

StewardManscat
01-24-2005, 05:05 PM
Good eye. I will need to add that myself when we get some search results! Without actually doing it, the proocedure is the same as above: you will need to add those same two lines of code. One to requires the parsing functions, one to parse the description.

The model to use the same is in browselinks above. Find


// Get Links
$getlinks = $DB_site->query("SELECT $votequery links.linkid, name, links.description, url, links.catid, views, links.username, links.userid, links.dateline, open, votenum, votetotal, links_categories.title $query[postfields] $query[subfields] $query[favfields]


add above:

require_once('./includes/functions_bbcodeparse.php');

Find:


while ($links = $DB_site->fetch_array($getlinks))
{
$linkbits .= construct_linkbits($links, $highlight);
}


Change to:



while ($links = $DB_site->fetch_array($getlinks))
{
$linkbits .= construct_linkbits($links, $highlight);
$link['description'] = parse_bbcode2($link['description'], false,true,true,true);

}


That is off the top of my head. It occurs to me now perhaps this mod belongs in construct_linkbits(). Then it is done once and for all.

But this should get you going today! Happy linking.

Torqued
01-24-2005, 06:48 PM
Hrm. That didn't fix it. I applied those changes to search.php, but nothing changed.

Any more ideas?

StewardManscat
01-24-2005, 07:42 PM
Sorry about that. Dunno why I think I can write code without trying it out first.

Here is the better solution. It replaces everything else. It is important to use this fix instead of all the gibberish in this thread so far (so that stripslashes works on the description before parsing).

Also, this does it for all linkbit templates, search, browse or whatever.

In function_links.php Find


// #################### Construct Linkbit ######################
function construct_linkbits($link, $highlight = '')
{



Add above:



require_once('./includes/functions_bbcodeparse.php');



In the same function, find:



eval('$linkbits .= "' . fetch_template('adv_links_linkbit') . '";');
return $linkbits;
}


Add above:



$link['description'] = parse_bbcode2($link['description'], false,true,true,true);


Thank you for your patience.

Torqued
01-24-2005, 09:07 PM
Hrm. Ok. It works for the other search stuff, but doesn't seem to be working in showlink.

see this example:

http://www.informaticsnurse.com/links/showlink.php?do=showdetails&l=165

also, if you do a search for "SCHIN", it does weird things to the highlighting in search.php.

:(

StewardManscat
01-24-2005, 09:21 PM
Sorry bud. Been putting out fires and my own site and not really giving this issue the attention it deserves. Rather than give you another half-cooked message please let me tackle it in the morning right fresh. Possibly Wednesday morning.

Besides, I may be in over my head. Remember I posted here asking what I had missed! Looks like you may have found it.

But if you are patient, I will fix it and post here. According to Brian there shouldn't be any reason it won't work, so let's not disappoint him eh?

Torqued
01-24-2005, 09:39 PM
Sorry bud. Been putting out fires and my own site and not really giving this issue the attention it deserves. Rather than give you another half-cooked message please let me tackle it in the morning right fresh. Possibly Wednesday morning.

Besides, I may be in over my head. Remember I posted here asking what I had missed! Looks like you may have found it.

But if you are patient, I will fix it and post here. According to Brian there shouldn't be any reason it won't work, so let's not disappoint him eh?

Sounds good to me. :) I'd love to see this functionality work!

The reason I want to be able to do BBCode in the link descriptions is because I want to create a "Book Store" category in my Links Directory and put in book images, descriptions, and have links w/ my Amazon Associate code in the links to the books. :D

StewardManscat
01-26-2005, 09:31 AM
Here is the sum total of the MOD again. Two changes. It seems to be working for for me in show, browse, and search results:

1. In showlink.php

Find



$link['name'] = stripslashes($link['name']);
$link['description'] = stripslashes($link['description']);
$link['directory'] = stripslashes($link['title']);
$link['username'] = stripslashes($link['username']);
$link['views'] = number_format($link['views']);
$link['dateadded'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['timeadded'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['keywords'] = stripslashes($link['keywords']);


Add below:


require_once('./includes/functions_bbcodeparse.php');
$link['description'] = parse_bbcode2($link['description'], false,true,true,true);




2. In includes/functions_links.php

Find


function construct_linkbits($link, $highlight = '')
{
global $vboptions, $vba_options, $stylevar, $bbuserinfo, $vbphrase, $returnto, $show, $adv_sorturl, $catid;

$link['name'] = stripslashes($link['name']);
$link['description'] = stripslashes($link['description']);
$link['username'] = stripslashes($link['username']);
$link['updatedate'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['updatetime'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['category'] = stripslashes($link['title']);
$link['replies'] = number_format($link['posts']);
$link['views'] = number_format($link['views']);
$link['lastpostdate'] = vbdate($vboptions['dateformat'], $link['lastpostdateline']);
$link['lastposttime'] = vbdate($vboptions['timeformat'], $link['lastpostdateline']);
$link['lastpostusername'] = stripslashes($link['lastpostusername']);


Add above:



require_once('./includes/functions_bbcodeparse.php');



Add below:



$link['description'] = parse_bbcode2($link['description'], false,true,true,true);



Again, the additional paratmeters to bbpasrecode2 are hard-coded for my site. If you allow HTML, or disallow smilies etc then you may need to tweak. I'm sure the global settings are kicking around somewhere, someone with more experience might be able to plug them in.

I also hacked links to include images, and that seems to be working ok for me. The code is kicking around this forum somewhere.

Good luck.

Torqued
01-26-2005, 04:41 PM
Ooo.. can't wait to try it tonight.. I'll let ya know if I can find another way to break it! ;) Thanks!!

Torqued
01-26-2005, 06:45 PM
:(

Have a look at this link:

http://www.informaticsnurse.com/links/showlink.php?do=showdetails&l=164&catid=6

then look at it here:

http://www.informaticsnurse.com/links/browselinks.php?c=6

The PRODIGY - UK Decision Support Software is about halfway down the page.

It's displaying like this:


PRODIGY guidance <br />
<br />
PRODIGY guidance offers advice on the management of conditions and symptoms that are commonly seen in primary care. The guidance is advisory and has been developed to assist healthcare professionals, together with patients, make decisions about the management of the patient's health. It is intended to support discussion and shared decision-making, and is not a substitute for sound clinical judgment or seeking medical advice where appropriate. Should you require medical advice please contact your own general practice or <a href="http://www.nhsdirect.nhs.uk/" target="_blank">NHS Direct</a>.<br />
<br />
PRODIGY guidance is available from the website in a variety of formats. Click on the links to access these.<br />
<br />
The full text <a href="http://www.prodigy.nhs.uk/ClinicalGuidance/ReleasedGuidance/GuidanceList.asp" target="_blank">guidance</a> provides both concise information to support decision-making in the consultation and more detailed background information for use as a learning resource. <br />
<br />
<a href="http://www.prodigy.nhs.uk/QuickReferenceGuides/" target="_blank">Quick reference guides(QRGs)</a> summarize the key management options and link these to concise supporting information and prescription details.<br />
<br />
<a href="http://www.prodigy.nhs.uk/PILs/index.asp" target="_blank">Patient Information Leaflets (PILs)</a> provide guidance for people who are not healthcare professionals and give an overview of the condition; advice on self-management; information on treatment options; and sources of further help. <br />
<br />

StewardManscat
01-26-2005, 07:34 PM
Double-check your changes to includes/functions_link.php ?

Torqued
01-26-2005, 08:37 PM
Double-check your changes to includes/functions_link.php ?

woops! got it! found some code left over from the earlier attempts at this. :D

absolutepunknet
06-27-2005, 05:14 PM
fixed

Benjamini
08-19-2005, 09:18 PM
Here is the sum total of the MOD again. Two changes. It seems to be working for for me in show, browse, and search results:

1. In showlink.php

Find



$link['name'] = stripslashes($link['name']);
$link['description'] = stripslashes($link['description']);
$link['directory'] = stripslashes($link['title']);
$link['username'] = stripslashes($link['username']);
$link['views'] = number_format($link['views']);
$link['dateadded'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['timeadded'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['keywords'] = stripslashes($link['keywords']);


Add below:


require_once('./includes/functions_bbcodeparse.php');
$link['description'] = parse_bbcode2($link['description'], false,true,true,true);




2. In includes/functions_links.php

Find


function construct_linkbits($link, $highlight = '')
{
global $vboptions, $vba_options, $stylevar, $bbuserinfo, $vbphrase, $returnto, $show, $adv_sorturl, $catid;

$link['name'] = stripslashes($link['name']);
$link['description'] = stripslashes($link['description']);
$link['username'] = stripslashes($link['username']);
$link['updatedate'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['updatetime'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['category'] = stripslashes($link['title']);
$link['replies'] = number_format($link['posts']);
$link['views'] = number_format($link['views']);
$link['lastpostdate'] = vbdate($vboptions['dateformat'], $link['lastpostdateline']);
$link['lastposttime'] = vbdate($vboptions['timeformat'], $link['lastpostdateline']);
$link['lastpostusername'] = stripslashes($link['lastpostusername']);


Add above:



require_once('./includes/functions_bbcodeparse.php');



Add below:



$link['description'] = parse_bbcode2($link['description'], false,true,true,true);



Again, the additional paratmeters to bbpasrecode2 are hard-coded for my site. If you allow HTML, or disallow smilies etc then you may need to tweak. I'm sure the global settings are kicking around somewhere, someone with more experience might be able to plug them in.

I also hacked links to include images, and that seems to be working ok for me. The code is kicking around this forum somewhere.

Good luck.

thx a lot !!! very usefull :)

absolutepunknet
12-01-2005, 04:17 AM
To do this in Vb3.5

http://www.vbulletin.org/forum/showthread.php?t=82693&page=1&pp=15

There's the tutorial, just use their code in the same spots. Works great for me!

require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$link['description'] = $parser->do_parse($link['description'], 0, 1, 1, 1, 1, 1, 0);