General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Dynamic List Start Number

  • scotth

    Dynamic List Start Number

    Participants 1
    Replies 2
    Last Activity 9 years, 10 months ago

    I have a customer that currently provides a starting number attribute on their ordered list xml. This is similar to the start attribute on the html ol tag. Is there an easy way to get a numbered list to start with a number provided in an attribute within xmetal or will I need to dynamically modify the css in a similar fashion to what is discussed in the thread below?

    [url=http://forums.xmetal.com/index.php/topic,686.0.html]http://forums.xmetal.com/index.php/topic,686.0.html[/url]

    Reply

    scotth

    Reply to: Dynamic List Start Number

    I forgot to mention that I am using version 6.

    Reply

    Derek Read

    Reply to: Dynamic List Start Number

    The following CSS would probably do it but you need to make sure to define a selector to match every possible value for the “starting number” attribute:


    numberedlist { counter-reset: item 0 }
    numberedlist[startnumber="1"] { counter-reset: item 0 }
    numberedlist[startnumber="2"] { counter-reset: item 1 }
    numberedlist[startnumber="3"] { counter-reset: item 2 }
    numberedlist[startnumber="4"] { counter-reset: item 3 }
    numberedlist[startnumber="5"] { counter-reset: item 4 }
    numberedlist[startnumber="6"] { counter-reset: item 5 }
    ...etc...

    listitem:before {
    content: counter(item) ". ";
    }

    listitem {
    display:block;
    counter-increment: item;
    }

    …note the fallback (where a specific value is not defined) on the first line. Without this, values that don't match any of the values you have defined won't restart the list and would continue the number from any that did match (lists appearing before it). If the schema enforces validity to that level then it would be less of an issue, but you would still need it there if the attribute was optional (and means start from 1).

    I suspect this is likely “good enough”. If not, then I think you'd be looking at a more complex scripting solution that uses the CSS styling APIs and some additional logic, but hopefully you can avoid that as it introduces other complexities.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support