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)

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

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

By steve_e - March 11, 2010

Thanks Chris. [:)]