MultiSearch display label for field

8 posts by 2 authors in: Forums > CMS Builder
Last Post: January 29, 2015   (RSS)

By claire - January 27, 2015

Hi Deborah - the :label field is only filled in when using getRecords. Are you using that function here?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Deborah - January 27, 2015

Claire, sorry to have not included that in my original post. I am using the following:

  // list of articles
  list($articlesRecords, $articlesMetaData) = getRecords(array(
    'tableName'   => 'articles',
    'orderBy'    => "date DESC",
    'useSeoUrls' => true,
  ));

~ Deborah
  

By claire - January 27, 2015

Okay, that's a little odd. Still though - you can get a list of the schema fields by using the following:

$fields = getSchemaFields($tablename);

From this, you can loop through the array until you get to the field you want, and then get the labels from that.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Deborah - January 28, 2015

Claire, I now understand why you said, "... that's a little odd." Your hint told me the code I had should work, so I did some testing and if the 'author' list values were to be managed from within the 'articles' table, the labels are displayed.

However, in my scenario, the 'authors' list choices are coming from an external table, as:

Section Editor: articles

Get options from database (advanced)
tablename: article_authors
option values: num
option labels: author_name_title

I would like to display the label for 'author_name_title' chosen in the 'articles' displayed on the search results page.

Considering these are possibly "related records", can what I want to accomplish still be done, or is the external table too far removed? (I hope I have the correct terminology. My apologies, if not.)

~ Deborah

By claire - January 28, 2015

Hi Deborah

No, this is fine, you can still do it. What you'll need to do is run a getRecords to get the author information, then sort the array by num so that it's easily accessible to the articles records.

This requires some knowledge of how arrays work, but it's nothing too difficult. Does that make sense?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Deborah - January 28, 2015

Claire, I love how your brain works! Mine is in a slower (learning gear) as regards PHP, so I'll have to further explore your suggestion. Meanwhile, thanks so much for the help and I'll post back here with my findings.

~ Deborah

By claire - January 29, 2015

No bother, let me know if you're having problems with it.

Honestly - if you can wrap your head around array handling in PHP, you can do almost anything in your viewer files.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/