Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: b0x on December 18, 2004, 06:09:50 AM

Title: Numbered list
Post by: b0x on December 18, 2004, 06:09:50 AM
Is it possible to have a numbered list instead of this:
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 06:15:42 AM
Not as standard, but it would be an easy mod (trivial if you want ordered lists *instead* of unordered, but not hard to offer both).
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 06:26:47 AM
For a quick hack, search Subs.php for:

// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['list']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',


And add after:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => isset($disabled['olist']) || isset($disabled['li']) ? '' : '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[/olist\](?:<br />)?~i' => isset($disabled['olist']) || isset($disabled['li']) ? '' : '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['olist']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',


And type 'olist' instead of 'list' for the tags.
Title: Re: Numbered list
Post by: b0x on December 18, 2004, 06:35:47 AM
Great! Thanks! ;D
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 06:41:16 AM
PS Needs a little tweaking because some of the alternate list style tags (eg #) still produce their unordered bullet styles, but it's fine with 'li' and I'll sort the others soon.
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 06:55:39 AM
Don't think it's worth modifying further because that'd involve the 'li' as well as 'list' tags so, on second thoughts (and because the results of # etc. are hardly catastrophic), I'd just stick to posting with the valid opening and closing 'li' tags.
Title: Re: Numbered list
Post by: b0x on December 18, 2004, 07:19:40 AM
Thanks for the help Peter!
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 08:15:21 AM
Just realised (after deciding to upload this to one of my sites) that I've inadvertently posted CVS code where things have been changed. So the equivalent hack for RC2 should be to search Subs.php for:

// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


And add after:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[/olist\](?:<br />)?~i' => '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


Sorry about that!
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 02:57:09 PM
Also just discovered that the new 'olist' tag isn't recognised by the 'printpage' action, but I did say it was a *quick* hack. So you might be interested in Anguz's Custom BB Code mod, but I might equally well finish the ordered list tag properly sometime (which should also mean including some alternative list styles) because it's something I've always missed too.
Title: Re: Numbered list
Post by: Peter Duggan on December 18, 2004, 03:28:15 PM
Quote from: Peter Duggan on December 18, 2004, 02:57:09 PM
which should also mean including some alternative list styles

Here we go again:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[olist style=la\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: lower-alpha;">',
'~\[olist style=ua\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: upper-alpha;">',
'~\[olist style=lr\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: lower-roman;">',
'~\[olist style=ur\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: upper-roman;">',
'~\[/olist\](?:<br />)?~i' => '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


Lower/upper alpha and lower/upper roman styles (haven't bothered with decimal because you'll get that by default with no 'style=' attribute). So type

[olist style=la]

For lower alpha,

[olist style=ua]

For upper alpha,

[olist style=lr]

For lower roman and

[olist style=ur]

For upper roman.
Title: Re: Numbered list
Post by: b0x on December 18, 2004, 05:35:35 PM
 :) Very cool!

Thanks!
Title: Re: Numbered list
Post by: Sandwich on November 07, 2005, 11:43:02 AM
Sorry to bump this, but is there any chance of getting an updated and working version of this? Perhaps make it into a MOD?