Toggle Content

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
macavity $ 20.00
heliown $ 20.00
rosbif $ 18.68
rosbif $ 26.40
Aforo, losViajeros $ 40.00

Recommended ISP

Tables in BBCode! Updated!

Dragonfly issues as they relate to modules discussed here
Responder al temaResponder al tema Versión Imprimible
Ir a página 1, 2, 3  Siguiente

Tables in BBCode! Updated!

Envio Publicado: Wed Apr 29, 2009 2:49 pm

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
  • Descripción: Add image files to theme/{yourtheme}images/bbcode - these are design to match those from Eestlane's marvellous reDesign theme
  • Nombre de archivo: newbbcode.zip
  • Tamaño de archivo: 11.12 KB
  • Descargado: 198 Time(s)

    lang_bbcode.php.txt
  • Descripción: Remove trailing .txt and replace copy in languages/english/Forums
  • Nombre de archivo: lang_bbcode.php.txt
  • Tamaño de archivo: 13.92 KB
  • Descargado: 174 Time(s)


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


Ultima edición por layingback el Fri Oct 23, 2009 10:21 am, editado 2 veces

layingback
Site Admin
Site Admin
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Tue May 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.5/9.2.1

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Tue May 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! Riendo

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
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Tue May 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.5/9.2.1

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Tue May 12, 2009 9:30 am

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

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
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Fri 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
 
Mensajes: 5
Registrado: Mar 26, 2007

Re: Tables in BBCode! Done!

Envio Publicado: Fri 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
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Fri 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
 
Mensajes: 5
Registrado: Mar 26, 2007

Re: Tables in BBCode! Done!

Envio Publicado: Tue 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

Code:
[list][*]text[/*][/list]

gives

  • text[/*]


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

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Sun 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
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Sun 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.5/9.2.1

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Mon 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
 
Mensajes: 1119
Registrado: Mar 18, 2006

Re: Tables in BBCode! Done!

Envio Publicado: Thu 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.5/9.2.1

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Sun 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.5/9.2.1

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France

Re: Tables in BBCode! Done!

Envio Publicado: Fri Oct 16, 2009 10:08 am

Any thoughts on these last two posts (now that 3.2 is launched!!) Guiño

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

rosbif
BetaTester
BetaTester
 
Mensajes: 424
Registrado: Aug 01, 2007
Ubicación: Chantilly, France
Link  QR  Share this Versión Imprimible  facebook   myspace   twitthis  
Show more ...
Mostrar mensajes de anteriores:   
Responder al temaResponder al tema Página 1 de 3 Ir a página 1, 2, 3  Siguiente

Dragonfly

Cambiar a:  



Puede publicar nuevos temas en este foro
No puede responder a temas en este foro
No puede editar sus mensajes en este foro
No puede borrar sus mensajes en este foro
No puede votar en encuestas en este foro
You cannot attach files in this forum
Tu puedes descargar archivos en este foro

Todas las horas son GMT