ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to retrieve a custom field values with weblog:entries and show each value only once

April 26, 2010 2:32pm

Subscribe [1]
  • #1 / Apr 26, 2010 2:32pm

    giusi

    94 posts

    Hi,

    I have a custom field in a channel from whom i have to retrieve the values to make a list. The custom field host a limited set of values but these values can repeat across entries (example: 10 post with value of Connecticut, 13 post with value of Minnesota and so on).

    The field must be a input text (no pre-filled dropdowns and the likes) so when i retrieve the value with weblog:entries I have each value repeatedly shown.

    How (if possible) can i tell to the engine to show each value only once? 

    Thanks

  • #2 / Apr 26, 2010 2:56pm

    ender

    1644 posts

    a custom SQL query leaps immediately to mind:

    SELECT DISTINCT
        field_id_XX AS my_custom_field
    FROM
        exp_weblog_data
    WHERE
        weblog_id = 2
    ORDER BY field_id_XX ASC;

    where the XX in field_id_XX is replace by the proper field_id for your custom field, using the proper value for weblog_id, and changing my_custom_field to whatever is appropriate.

  • #3 / Apr 26, 2010 3:03pm

    giusi

    94 posts

    ender, thank you very much for your istant support!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases