Adding a variable number of links to a detail page

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 11, 2010   (RSS)

By steve_e - March 9, 2010

Hi -
I can't think of a way of doing this although it may be simple (or possible with a later version; I'm currently still on 1.22)?

I'd like to be able to allow my editors to add a variable number of links to forum conversations into a newsletter. The links would need to have a title, the URL and a pulled quote from the discussion, so three different elements.

I could allow them to do this just by creating a wysiwyg text box and allowing them to edit the three elements in themselves. However to avoid the risk of formatting problems and inconsistencies, I'd rather have them inputting it via three separate fields which I then format via the detail page template for each newsletter.

But I can't see a way of breaking it down in this way when there will be a variable number of instances. I suppose what I want is something similar to the uploads or images dialogue, where you add a caption, an image and so on to each instance of a field. And can add an indefinite number of them to a record.

Does that make sense?

Re: [steve_e] Adding a variable number of links to a detail page

By Chris - March 9, 2010

Hi steve_e,

The simplest solution may be to create a bunch of fields and leave the ones you aren't using blank. For example, you could have link_title_1, link_url_1, link_quote_1, ... link_quote_8. This approach would set a maximum on the number of "links" you could add, and would make the edit page a little cumbersome with extra, unused fields, but it is fairly simple.

Another approach would be to create a new section with four fields: title, url, quote, and a conversationNum to associate a "link" record with a "conversation". You can do this with a list field set to "Get options from database (advanced)". We've recently added functionality to display "related records", but we don't have any way yet to add related records. I'm hoping we can provide a much better solution for you in the near future. :)

I hope this helps. Please let em know if you have any questions.
All the best,
Chris

Re: [chris] Adding a variable number of links to a detail page

By steve_e - March 10, 2010

Thanks for this Chris. Just to clarify then (I'm not much good at db concepts!) the conversationNum field would be the link to a particular newsletter, so however many conversations you'd want to include in the March Newsletter, you'd give a value of something like 'Mar2010' to and then reference this in the detail page of the March Newsletter?

Re: [steve_e] Adding a variable number of links to a detail page

By Chris - March 10, 2010

Hi steve_e,

Essentially, yes. It's safer to use the "num" of the record (i.e. newsletter) you're linking to because the num won't change.

You'd probably do something like this in your detail page:

list($newsletterRecords, ) = getRecords(array(
'tableName' => 'newsletter',
'where' => whereRecordNumberInUrl(1),
));
$newsletterRecord = @$newsletterRecords[0];
if (!$newsletterRecord) { die("Could not find newsletter record"); }

list($linkRecords, ) = getRecords(array(
'tableName' => 'link',
'where' => mysql_escapef("newsletterNum = ?", $newsletterRecord['num']),
));


I hope this helps. Please let me know if you have any questions.
All the best,
Chris