_TOGGLE

Donations

Donate with PayPal!
Help support Pro_News and become a member of our Sponsors Group
The tip jar is at PayPal, but does not require a PayPal account
Anonym $ 10.00
macavity $ 115.00
RedGerry £ 50.00
Anonym $ 10.00
minor $ 20.00

Recommended ISP

Tables in BBCode! Updated!

Dragonfly issues as they relate to modules discussed here
Svar på EmneSvar på Emne Utskriftsvennlig side
Gå til side 1, 2, 3  Neste

Tables in BBCode! Updated!

Innlegg Skrevet: Ons Apr 29, 2009 2:49 pm

UPDATE: This thread has got very long and complex and the nbbcode hack has developed. It's at a pretty complete stage now, so starting a fresh thread here.

I needed basic table support, plus lists, and got to realising that if I needed it I'd better do it myself! So here it is...

Please note this is only basic table support. You can enter BBCodes that match their HTML equivalents table /table, tr /tr, th /th and td /td. Nothing fancy like colspan is supported. My goal was simple tables, to be entered by end-users to whom I didn't want to give HTML access - not because I didn't trust them, but because they might accidentally leave an open-ended HTML command... All of these have buttons, both on and off, help and FAQ entries.

While I was at it, I added buttons for the list BBCode functions that are already in the code. Plus 2 other functions that I like: IMGURL which lets you accomplish an img within a[url /url in a single operation (thanks to mikiemouse of EHP Designs for coding that), and PDFURL which places a URL link to a pdf and drops in the Adobe pdf icon automatically.

Finally an updated BBCode FAQ and a prominent link to it.

You will need to login to see the attachments.

Hope they are useful to someone.

I know of 1 problem with the table BBCodes: if you concatenate the table, tr and td codes without line breaks the table appears as you would expect. However if you, say, place each tr or td on its own line, then those line breaks are going to appear as extra br's above the table. I believe that these can be eliminated in the preg_replace command, but I couldn't figure out what code to look for. If anyone knows, I'll update.

Insert in includes/nbbcode.php starting at line 190

PHP:
	var imgurl_help = "'. $bbcode_common['imgurl'][0].' '.$bbcode_common['imgurl'][1].'";
var pdfurl_help = "'. $bbcode_common['pdfurl'][0].' '.$bbcode_common['pdfurl'][1].'";
var table_help= "'. $bbcode_common['table'][0].' '.$bbcode_common['table'][1].'";
var tr_help= "'. $bbcode_common['tr'][0].' '.$bbcode_common['tr'][1].'";
var th_help= "'. $bbcode_common['th'][0].' '.$bbcode_common['th'][1].'";
var td_help= "'. $bbcode_common['td'][0].' '.$bbcode_common['td'][1].'";
var list_help = "'. $bbcode_common['list'][0].' '.$bbcode_common['list'][1].'";
var nlist_help = "'. $bbcode_common['nlist'][0].' '.$bbcode_common['nlist'][1].'";
var alist_help = "'. $bbcode_common['alist'][0].' '.$bbcode_common['alist'][1].'";
var ilist_help = "'. $bbcode_common['ilist'][0].' '.$bbcode_common['ilist'][1].'";
var li_help = "'. $bbcode_common['li'][0].' '.$bbcode_common['li'][1].'";



Also starting at line 273

PHP:
	if ($allowed) {
$content .= '
</td>
</tr><tr>
<td>
<img alt="'
.$bbcode_common['imgurl'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'imgurl\')" onclick="BBCimg(\''.$form.'\',\''.$field.'\',\'imgurl\')" src="'.$bbbttns_path.'imgurl.gif" />
&nbsp;&nbsp;
<img alt="'
.$bbcode_common['list'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'list\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'list\')" src="'.$bbbttns_path.'ulist.gif" />
<img alt="'
.$bbcode_common['nlist'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'nlist\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'list\',this,\'1\')" src="'.$bbbttns_path.'list_1.gif" />
<img alt="'
.$bbcode_common['alist'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'alist\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'list\',this,\'a\')" src="'.$bbbttns_path.'list_a.gif" />
<img alt="'
.$bbcode_common['ilist'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'ilist\')" onclick="BBCode(\''.$form.'\',\''.$field.'\',\'list\',this,\'i\')" src="'.$bbbttns_path.'list_i.gif" />
<img alt="'
.$bbcode_common['li'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'li\')" onclick="BBCli(\''.$form.'\',\''.$field.'\')" src="'.$bbbttns_path.'bullet.gif" />
&nbsp;&nbsp;
<img alt="'
.$bbcode_common['pdfurl'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'pdfurl\')" onclick="BBCpdf(\''.$form.'\',\''.$field.'\',\'pdfurl\')" src="'.$bbbttns_path.'pdfurl.gif" />
&nbsp;&nbsp;
<img alt="'
.$bbcode_common['table'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'table\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'table\')" src="'.$bbbttns_path.'table.gif" />
<img alt="'
.$bbcode_common['tr'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'tr\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'tr\')" src="'.$bbbttns_path.'tr.gif" />
<img alt="'
.$bbcode_common['th'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'th\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'th\')" src="'.$bbbttns_path.'th.gif" />
<img alt="'
.$bbcode_common['td'][0].'" class="bbcbutton" onmouseover="helpline(\''.$form.'\',\''.$field.'\',\'td\')" onclick="BBCcode(\''.$form.'\',\''.$field.'\',this,\'td\')" src="'.$bbbttns_path.'td.gif" />
&nbsp;&nbsp;&nbsp;
<a href="index.php?name=Forums&file=faq&mode=bbcode" target="_blank" class="tiny">BBCode FAQ</a>
'
;
}


Also starting at line 539

PHP:
			# [table] and [/table] for table.
$patterns[] = '#\[table\]\r?\n?\t?(.*?)\[/table\]\r?\n?\t?#si';
$replacements[] = '<table class="BBCtable" style="border:0" cellpadding="5">\1</table>';

# [tr] and [/tr] for table row.
$patterns[] = '#\[tr\]\r?\n?\t?(.*?)\[/tr\]\r?\n?\t?#si';
$replacements[] = '<tr>\1</tr>';

# [th] and [/th] for table title.
$patterns[] = '#\[th\]\r?\n?\t?(.*?)\[/th\]\r?\n?\t?#si';
$replacements[] = '<th>\1</th>';

# [td] and [/td] for table field.
$patterns[] = '#\[td\]\r?\n?\t?(.*?)\[/td\]\r?\n?\t?#si';
$replacements[] = '<td>\1</td>';

// [imgurl url= ]image_url_here[/imgurl] code..
$patterns[] = "#\[imgurl url=([\w]+?://[^ \"\n\r\t<]*?)]([\w]+(://|\.|/)[^ (\"\n\r\t<]*?)\[/imgurl\]#si";
$replacements[] = "<a href=\"\\1\" target=\"_blank\"><img src=\"\\2\" border=\"0\" alt=\"\" /></a>";

# [pdfurl url=xxxx://www.cpgnuke.com]cpgnuke[/pdfurl]
$patterns[] = "#\[pdfurl url=([\w]+://[^ (\"\n\r\t<]*?)\](.*?)\[/pdfurl\]#is";
$replacements[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\" class=\"postlink\" rel=\"nofollow\">\\2 <img src=\"images/pdf_icon.gif\" border=\"0\" alt=\"\" /></a>";



Insert in language/english/bbcode.php starting at line 104

PHP:
	'imgurl'    => array('URL with Image:','[imgurl url=Page URL]http://image path[/imgurl]'),
'pdfurl' => array('URL with PDF icon:','[pdfurl url=PDF URL]link text[/pdfurl]'),
'table' => array('Table:','[table]text[/table]'),
'tr' => array('Table row:','[tr]text[/tr] usage: [table][tr]text[/tr][/table]'),
'th' => array('Table title:','[th]text[/th] usage: [table][tr][th]text[/th][th]..[/th][/tr][/table]'),
'td' => array('Table field:','[td]text[/td] usage: [table][tr][td]text[/td][td]..[/td][/tr][/table]'),
'list' => array('Bulleted List:','[list]list[/list]'),
'nlist' => array('Numbered List:','[list=1]list[/list]'),
'alist' => array('Alpha List:','[list=a]list[/list]'),
'ilist' => array('Roman List:','[list=i]list[/list]'),
'li' => array('List item:','[*]text usage (all lists): [list][*]text[*]text [/list]'),



Update: You also need the following edits, listed further down this thread.
And you will require a PDF icon image if you want to display one, info later in this thread.


    newbbcode.zip
  • Beskrivelse: Add image files to theme/{yourtheme}images/bbcode - these are design to match those from Eestlane's marvellous reDesign theme
  • Filnavn: newbbcode.zip
  • Filstørrelse: 11.12 KB
  • Lastet ned: 214 gang(er)

    lang_bbcode.php.txt
  • Beskrivelse: Remove trailing .txt and replace copy in languages/english/Forums
  • Filnavn: lang_bbcode.php.txt
  • Filstørrelse: 13.92 KB
  • Lastet ned: 178 gang(er)


layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1


Sist endret av layingback den Man Apr 30, 2012 3:41 pm, endret 3 ganger totalt

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tir Mai 12, 2009 7:45 am

Have made these changes and looks like it works a treat! Thanks layingback.

Do you have an easy way of remembering what files you have edited? Only reason I ask is that when it comes to updating the site I tend to forget and end up overwriting all the little changes like this one



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tir Mai 12, 2009 8:05 am

- rosbif

Do you have an easy way of remembering what files you have edited?



Yeah! I create a website, and record them all on there! Ler

Also at a detail level I use a diff tool to compare new and old. Meld on Ubuntu, can't remember what I used to use on Windoze - it's been so long... CVS is best solution, but a bit of work to set up for all projects, so I reserve that just for the big stuff. Other possibility might be to save out diffs for all changes - assuming you have editor capable of this.



layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tir Mai 12, 2009 9:19 am

I knew it wouldn't be simple!

I haven't used a diff tool before so maybe I should go looking at one. Forum would be easiest I agree!

I'm using SuperEdi as my editor but it doesn't seem to be that happy in vista. What do you use?



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tir Mai 12, 2009 9:30 am

Geany, although Notepad++ is pretty good under Windoze. Of course, nothing's very good under Vista Vink



layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Fre Jun 05, 2009 12:10 am

Is it possible to implement this with the NBBCode module from ehpdesigns.com?

I tried and got an error, so I was wondering if I was trying to do the impossible with no hope of success.

Thanks.



warden's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
L-2.26 A-1.3.3 M-5.0x P-5.0x DF-9.2.1

warden
Newbie
Newbie
 
Innlegg: 5
Ble medlem: Mar 26, 2007

Re: Tables in BBCode! Done!

Innlegg Skrevet: Fre Jun 05, 2009 10:14 am

warden, it should be quite straightforward I would have thought, although the locations and perhaps a few variable names will be different. But to be honest I don't have the time or the inclination to potentially mess up EHP's fine module. It may happen that I need it, but currently I have NBBCode for some sites and my Tables code on others - I've not needed both on the same site, as yet.

But I did post a feature request on EHP's site for you ...



layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Fre Jun 05, 2009 2:46 pm

Thank you.



warden's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
L-2.26 A-1.3.3 M-5.0x P-5.0x DF-9.2.1

warden
Newbie
Newbie
 
Innlegg: 5
Ble medlem: Mar 26, 2007

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tir Jun 23, 2009 11:45 am

I've just discovered that the list function doesn't seem to work. [list] just appears as [list] without being translated. It does funny things here on your site too if you follow the format shown in the hover tip..

Have I done something wrong?

eg

Kode:
[list][*]text[/*][/list]



gives

  • text[/*]



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Søn Jun 28, 2009 6:36 pm

Should be:

  • text
  • text
  • text

Click on BBCode FAQ for instructions



layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Søn Jun 28, 2009 8:05 pm

Ah ok, it's correct in the FAQ but the mouseover instructions by the bullet are wrong..



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Man Jun 29, 2009 9:08 am

Thanks. Yes, too late to fix last nite, but edited now I believe. Last line of last insert.



layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback
Site Admin
Site Admin
 
Innlegg: 1229
Ble medlem: Mar 18, 2006

Re: Tables in BBCode! Done!

Innlegg Skrevet: Tor Sep 03, 2009 12:23 pm

I seem to have a problem now with URL with Image, List Item and URL with PDF. The error shows up as Line 826, submit.html, object expected.

Incidentally there's a reference to images/pdf_icon.gif which I don't seem to have. Should I have that from somewhere?



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Søn Sep 13, 2009 10:44 am

Also, I think I mentioned this before somewhere but can't remember where, pressing any BBCode button always puts the code at the bottom of the text, rather than around the highlighted text for example...



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France

Re: Tables in BBCode! Done!

Innlegg Skrevet: Fre Okt 16, 2009 10:08 am

Any thoughts on these last two posts (now that 3.2 is launched!!) Vink



rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif
BetaTester
BetaTester
 
Innlegg: 492
Ble medlem: Aug 01, 2007
Bosted: Chantilly, France
Link  QR  Share this Utskriftsvennlig side  facebook   myspace   twitthis  
Show more ...
Vis Innlegg fra:   
Svar på EmneSvar på Emne Side 1 av 3 Gå til side 1, 2, 3  Neste

Dragonfly

Gå til:  



Du kan ikke starte nye emner i dette forumet
Du kan ikke svare på emner i dette forumet
Du kan ikke endre dine egne innlegg i dette forumet
Du kan ikke slette dine egne innlegg i dette forumet
Du kan ikke delta i avstemninger i dette forumet
Du kan ikke legge til filer i dette forumet
Du kan laste ned filer fra dette forumet

Alle klokkeslett er GMT






layingback Non-Human Terms of Use