tmatbcorp VIP
Total posts: 41
04 Фев 2015 13:43

Hi,

I have a type myType with two fields: field1 and field2.

On the list articles view for this type, I would like to display only the records which have field1 = some specific value.

Example:

  • record1 : field1 = 2, field2 = title1
  • record2 : field1 = 0, field2 = title2

=> display only records where field1 > 0 => display only record1

Is that possible?

Regards

Последние изменения: 15 Июнь 2017


geojoomla
Total posts: 73
04 Фев 2015 14:46
  1. In my opinion, this question should go to Cobalt, not General - it's a very specific one.

  2. I'm also interested, but considering my previous question regarding recurring articles, I don't think it's possible. As you can see there, you can't hide articles, but you could "hide fields" by putting conditions into record templates.

Better professionals here will hopefully clarify you. G


tmatbcorp VIP
Total posts: 41
04 Фев 2015 15:21

Hi,

Subject moved to Cobalt 8 forum, you're right, I had not seen it was with general questions.

I have just read your topic and the solution that has been given to you can work but not in all cases.

Actually I have two templates on which I have to display records the way I said above :

  • a template with the list of all the records from myType: there writing if field not the right value then don't display is working fine (even if it would be prettier to have the WHERE clause performed in the SQL request)
  • a slider module on front page which shows 6 random records: if I use the previous solution, I will have 0 to 6 records left since the SQL request with LIMIT 6 has already been performed. Not what I want then because I need to have always 6 records in the slider

Thanks for your answer anyway!


geojoomla
Total posts: 73
04 Фев 2015 15:51

Just thinking loud... Can't you (looks like you know what you're talking about) or Mint team put a condition of min/max records to be shown? Some similar logic of "compulsory field" when inputting, but for showing (?) No idea if possible, just asking...

As for "if field not the right value then don't display" - I actually remember smth like this long time ago - during Mighty Components


pepperstreet VIP
Total posts: 3,837
04 Фев 2015 18:11

FYI - the Records Module has a new parameter to display records with a certain field value.

Bildschirmfoto 2015-02-04 um 18.49.53


To accomplish a similar behavior on the regular list view:

A.) You would have to create a custom template with conditional field check.
For the limit, you might use the pagination in template parameters: Set limit per page, hide pagination and limit box. (Or take a look into the files that generate the RSS feed. There is a limit, too.)

B.) Create a pre-filtered link (docs article)


tmatbcorp VIP
Total posts: 41
06 Фев 2015 15:57

Hi,

Thank you both for your answers.

I finally used what pepperstreet said:

  • what to show: Field value equal to
  • field: the field I wanted to sort according to
  • field value: 0

What I trully want is to display all articles for this type where field value > 0.

Then I did something not very pretty. In /www/modules/mod_cobalt_records/mod_cobalt_records.php file, I changed

$query->where('field_value = ' . $db->quote($params->get('field_value')));

to

if($params->get('section_id') == 15 && strstr($params->get('tmpl'), 'adt_mod_metiers_recrutent')) 
    $query->where('field_value > ' . $db->quote($params->get('field_value')));

Yes my if is really ugly but it does what I want without normally affecting anything else... :)

May I suggest to add in Cobalt 9 for cobalt module records:

  • field value more than
  • field value less than
  • field value between

Kind regards,


Sergey
Total posts: 13,748
09 Фев 2015 10:08

I added this parameter to the next version.


pepperstreet VIP
Total posts: 3,837
28 Май 2017 03:19

I've turned the topic into an idea. Wouldn't it make sense to have the same comparison options in Records field?

These are the field comparison options in Records module v.8.66
file

Работает на Cobalt