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)
Hello, just like cmsb upload fields for photos/graphics, etc. receives multiple files (pieces of data) and then on public list and detail pages we can show all that were uploaded with a single function (foreach loop) display the results?
Basically, I have the client enter just a youtube video id (no share code, etc. as I preprogrammed the page with all the wanted parameters) and that video shows. Works terrific but now the client wants to add many (think 20+) videos on a single page. It'd be a lot less cumbersome to just keep adding video id's to a single field area in a record instead of creating indivdual fields for every video.
does that make sense?
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.
interactivetools.com