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 show a field only once?

August 18, 2012 11:01am

Subscribe [2]
  • #1 / Aug 18, 2012 11:01am

    Ed Hebert

    49 posts

    I’m trying to create a “thank you” list for a client that recently ran a fundraising auction.

    The original auction item channel contained fields for donor name and auction item. Some donors contributed multiple items to the auction. I’d like my thank you page to list the name of each donor, but be smart enough to eliminate redundant listings of the same donor. Is there an easy way to accomplish this in EE?

    Thanks

  • #2 / Aug 20, 2012 2:16pm

    Shane Eckert

    7174 posts

    Hello Ed,

    Thank you for posting your question here on the ExpressionEngine forums.

    How are you wanting to create this list?

    You can always export using a custom query.

    Please let me know.

    Cheers,

  • #3 / Aug 20, 2012 3:03pm

    Ed Hebert

    49 posts

    Hi Shane-

    I’m find with a list output in any format…<ul>, <dl>, <div>...whatever. Is that what you mean?

    Could you provide an example of query syntax for such a request? My custom fields are {donor} and {auction_item}.

    Thanks

  • #4 / Aug 21, 2012 11:21am

    Shane Eckert

    7174 posts

    Hello Ed,

    I understand now. I thought you were wanting to export a list of donors into a spreadsheet.

    To print them out on the page you are going to get each entry. If you only want a username printed once, then you will need to limit the amount of results. There is an issue here in that a donor might exist for more than one entry if they donated multiple times.

    Can you show me what you have so far?

    Thank you,

  • #5 / Aug 21, 2012 11:56am

    Ed Hebert

    49 posts

    Shane-

    That’s EXACTLY the problem. Donors who have donated multiple times. That’s why I mentioned “Some donors contributed multiple items to the auction. I’d like my thank you page to list the name of each donor, but be smart enough to eliminate redundant listings of the same donor.”

    I know how to do a simple loop of my entries. My question is, is there a conditional that would easily compare & eliminate redundancies when the field contains duplicates?

    Thanks again

  • #6 / Aug 22, 2012 12:50pm

    Shane Eckert

    7174 posts

    Hey Ed,

    Can you show me what you have so far? I really need to see your template code, it would help to know what your channel looks like to help you.

    Cheers,

  • #7 / Aug 22, 2012 2:40pm

    Ed Hebert

    49 posts

    Hi Shane-

    Here’s my basic template code. Quite honestly, I just made this now for you, as I was waiting for an answer to my question before I made the template!

    {!-- Auction section index page --}
    
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>{exp:channel:entries channel="auction" limit="1"}{if segment_2}{title} - {/if}{/exp:channel:entries}{exp:channel:info channel="auction"}{channel_title}{/exp:channel:info} - {site_name}</title>
            {exp:channel:entries channel="auction" limit="1"}<meta name="description" content="{exp:tagstripper:stripAllTags}{brief}{/exp:tagstripper:stripAllTags}">{/exp:channel:entries}
            <meta name="description" content="Camp PARC Auction">  
            
            {embed="includes/head"}
            {embed="includes/analytics"}
        </head>
        <body>
        {embed="includes/nav"}
            
    
            {!-- Page Content
            ================================================== --}
            <div class="container">
                <div class="content">
                
                    <div class="row">
                        <div class="span7 offset2">
                            <h1>Thanks to Our Donors</h1>
                            Thanks to the kindness and generosity of the following businesses and individuals, we were able to raise over $100,000 this year!                        
                            <ul>
                            {exp:channel:entries channel="auction"}
                            
                                {!-- Heres where I need the conditional to eliminate redundant occurances  when the DONOR has donated more than one item --}
                                
                                <li>{if donor_url}<a href="http://{donor_url}">{/if}{donor}{if donor_url}</a>{/if}</li>
    
                            {/exp:channel:entries}
                        </ul>
                        </div>
                    
                    </div>  
                
                </div>
            </div>
            
            {embed="includes/footer"}
            <!-- Javascript includes
            ================================================== -->
            [removed][removed]
            [removed][removed]
            [removed][removed]
            [removed][removed]
            
        </body>
    </html>

     

  • #8 / Aug 23, 2012 11:01am

    Shane Eckert

    7174 posts

    Hello Ed,

    Gotcha.

    I do not see any easy way to do that with conditionals.

    My suggestion is to use the Query Module and write some SQL to select the usernames and omit duplicates.

    If you would like I can move this over to the Community Help Forum for some SQL help. I think will be your quickest and least painful option, using the Query Module.

    Thank you,

  • #9 / Aug 23, 2012 11:25am

    Ed Hebert

    49 posts

    Ok, Shane. I’ll try to lay out something with a SQL query. Thanks anyway!

    Ed

  • #10 / Aug 23, 2012 11:38am

    Shane Eckert

    7174 posts

    Hello Ed,

    Sounds good!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases