Jump to content

creating a li with PW


lecrackffm
 Share

Recommended Posts

Hello,

im porting my first static site to PW and still trying to get my head around all the options and logics..maybe you can help out.

I have a simple list (ul>li) of Names on the page, which i want my client to alter at any time.

Right now, the only option i see is to create a textfield with the CKEditor.

Is there a more more straight foreword way to accomplish this, like creating one field in which my client can put comma separated names, and i loop through this field in the template?

I tried to find something like this in the cheatsheet but im still struggling with all the options.

Thanks for your help.

Link to comment
Share on other sites

A repeater will work, but it's sort of overkill for repeating just a single line of text. Behind the scenes it is creating a page for every line.

3 minutes ago, Metaphora said:

Maybe just a textarea plus "TextformatterNewlineUL", which »converts newlines to <li> list items and surrounds in an <ul> unordered list«?

This is probably the way to go.

If you wanted your own custom markup you could explode and foreach a textarea.

$lines = explode("\n", $page->my_textarea);
if(count($lines)) {
    echo "<ul class='my-special-list'>";
    foreach($lines as $line) {
        echo "<li class='my-list-item'>$line</li>";
    }
    echo "</ul>";
}

 

2 minutes ago, lecrackffm said:

Also the profields multiplier seems good for this kind of task, right?

For sure, and for more complex repeatable items see the Table fieldtype.

  • Like 7
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...