Can a text field function like an upload field, and then use foreach loops to show multiple results on a details page?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 17   (RSS)

Hi Codee, 

If it's just URLs, what about just having a big text area field and listing the links one after another? 

You could then display them on the frontend with some code like this: 

// mockup some fake test data
$record['links'] = "
https://www.google.com/
https://www.yahoo.com/
https://www.bing.com/
";

// show links
$linkText = strip_tags($record['links']); // remove any <br> tags
$links    = explode("\n", $linkText);     // split on new lines
$links    = array_map('trim', $links);    // trim whitespace from each link
$links    = array_filter($links);         // remove empty links

foreach ($links as $link) {
    echo "$link\n";
}

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com

That makes sense and is close enough to what is needed. Thank you kindly!