Creating a block with lists

Permalink Browser Info Environment
I can see there is no direct way of adding an unordered or ordered list, so I was wondering what would be the best way to do this. Adding the opening and closing UL/OL tags as static html and then the list elements as text fields would do, but the number of list elements would be the static.

Any other way or ideas ?

Type: Discussion
Status: New
3patines
View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
jordanlev
This addon is not really designed for "repeating" or list information. Usually the way you handle that in Concrete5 is by making a custom template for the Page List block, putting that page list on a top-level page and then having each item in the list be a sub-page beneath that top-level page that the page list block will then pick up and show.

But if that's overkill for your situation and you're only dealing with simple text info, you could make a block with Designer Content that has a "Text Area" field, then after you've generated the field, edit the block's view.php file, find this code:
<?php echo nl2br(htmlentities($field_1_textarea_text, ENT_QUOTES, APP_CHARSET)); ?>

...and change it to this:
<?php
$items = explode("\n", $field_1_textarea_text);
foreach ($items as $item) {
    echo "<li>{$item}</li>";
}
?>

(in addition to putting the "<ul>" and "</ul>" tags as static HTML surrounding it)
3patines replied on at Permalink Reply
3patines
Worked like a charm, thanks ! Now, is there a way to input html tags into any filed (textbox, textarea) when editing the content ? For small things as <strong> or <em> ?

Thanks again
jordanlev replied on at Permalink Reply
jordanlev
Sure, just edit the view.php file of the block after you've created it and remove all calls to the "htmlentities" function. For example, if you see something like this:
<?php echo htmlentities($field_2_textarea_text, ENT_QUOTES, APP_CHARSET); ?>

...you would change it to this:
<?php echo $field_2_textarea_text; ?>


Although note that ideally you should probably use the "WYSIWYG" field when you want to allow rich text because then your end-users can just use the editing toolbar instead of having to know what the html codes are.
drumrby replied on at Permalink Reply
drumrby
This sounds like a perfect solution for something I've been looking for. However, when I follow the steps, all I get is an empty <li></li>. Do I need to be using a special markup in the text area when I am adding/editing this block?
drumrby replied on at Permalink Reply
drumrby
Nevermind, I figured out what was up. Stupid mistake. That's what I get for working late at night.

Works like a charm now. Thanks for all your hard work Jordan.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.