search-event-list.php

This topic contains 6 replies, has 2 voices, and was last updated by  Chris Hirst 8 years ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #25607

    I have been working on this all day, and thought I may as well ask the question now as I cannot work it out 🙁

    All I want to do is display the results from the above search form in rows. Rows that I can put headings over like in a table. I just need the thumbnail, linked Image title, Date and Venue.

    I am an absolute numpty at this. Could you wave your Harry Potter wand and magic a simple solution for me?

    Thanks very much
    Chris

    Chris Hirst
    #25614

    Hi Chris,

    How comfortable are you with using PHP and HTML? The template file is in event-organiser-pro/templates/search-event-list.php and it’s just a matter of copying that file to your theme an editing it.

    The while loop contains the mark-up for each event. So you’ll want to contain it within a <table>, and including <tr></tr> with headers (you also make use of <tbody> and <thead>.

    Inside the while loop, you’d replace <article>...</article> with <tr><td>..</td>...<td>..</td></tr>, where <td>...</td> contains the mark-up for that cell.

    Functions used for displaying event dates, title and thumbnail etc can be found in that template.

    If you need further assistance with this, please just ask 🙂

    Stephen Harris
    #25626

    Thanks for the help. I have made some adjustments that has taken me almost there, however each row is in it’s own table with it’s own header row.

    Being a little dim, I know something is just not right but I cannot see it. The page is still in the same page as in my previous message, I have replied to the email sent from the forum with the code I have.

    If you can just point out the format issue I should be out of your hair for a while.

    Thanks
    Chris

    Chris Hirst
    #25628

    Hi Chris,

    I won’t receive replies to that e-mail. Could you get in touch via this contact form or upload the template to a public code sharing site (e.g. gist)?

    Stephen Harris
    #25629

    Stephen,
    I have just sent a message through the contact form with a txt file attached with the page code as I have it as requested.

    Any help to bring this table under control would be greatly appreciated.

    Thanks
    Chris

    Chris Hirst
    #25641

    Thanks Chris,

    The biggest issue was simply that you had the table headers within the while loop, so they were printed for each row.

    Try this edited version:

    <?php
    
    global $eo_event_loop;
    
    //Date % Time format for events
    $date_format = get_option( 'date_format' );
    $time_format = get_option( 'time_format' );
    ?>
    
    <?php if ( $eo_event_loop->have_posts() ): ?>
    
        <?php if ( $eo_event_loop->max_num_pages > 1 ) :
            //See http://codex.wordpress.org/Function_Reference/paginate_links
            $big = 999999999; // need an unlikely integer
            echo paginate_links( array(
                'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
                'current' => max( 1, get_query_var( 'paged' ) ),
                'total' => $eo_event_loop->max_num_pages
            ) );
        endif; ?>
    
    
    <div class="container">            
      <table class="table table-hover">
        <thead>
            <tr>
                <th>Event</th>
                <th>Date</th>
                <th>Venue</th>
                <th>Category</th>
                <th>Book</th>
            </tr>
        </thead>
        <tbody>
    
        <?php while ( $eo_event_loop->have_posts() ): $eo_event_loop->the_post(); ?>
    
            <tr valign="middle" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <td>
                    <div class="entry-title" style="display: inline;">
                        <a href="<?php the_permalink(); ?>">
                        <?php
                        //If it has one, display the thumbnail
                        if ( has_post_thumbnail() )
                            the_post_thumbnail( 'thumbnail', array( 'style'=>'float:left;margin-right:20px;' ) );
    
                        //Display the title
                            the_title();
                        ?>
                        </a>
                    </div>
                </td>
    
                <td>
                    <!-- Output the date of the occurrence-->
                    <?php
                    //Format date/time according to whether its an all day event.
                    //Use microdata http://support.google.com/webmasters/bin/answer.py?hl=en&answer=176035
                    if ( eo_is_all_day() ) {
                        $format = 'd F Y';
                        $microformat = 'Y-m-d';
                    } else {
                        $format = 'd F Y '.get_option( 'time_format' );
                        $microformat = 'c';
                        }?>
                    <time itemprop="startDate" datetime="<?php eo_the_start( $microformat ); ?>"><?php eo_the_start( $format ); ?></time>
                </td>
    
                <td><!-- event venue -->
                    <a href="<?php eo_venue_link(); ?>"> <?php eo_venue_name(); ?></a>
                </td>
    
                <td><!-- Event category -->
                <?php if ( get_the_terms( get_the_ID(), 'event-category' ) ) { ?>
                    <?php echo get_the_term_list( get_the_ID(),'event-category', '', ', ', '' ); ?>
                <?php } ?>
                </td>
    
                <td>
                    <a href="<?php the_permalink(); ?>">Book</a>
                </td>       
    
            </tr>
        <?php endwhile; ?>
    
        </tbody>
      </table>
    </div>
    
    <?php if ( $eo_event_loop->max_num_pages > 1 ) :
            //See http://codex.wordpress.org/Function_Reference/paginate_links
            $big = 999999999; // need an unlikely integer
            echo paginate_links( array(
                'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
                'current' => max( 1, get_query_var( 'paged' ) ),
                'total' => $eo_event_loop->max_num_pages
            ) );
        endif; ?>
    
    <?php endif; ?>
    
    Stephen Harris
    #25650

    Doh!
    I just knew it was something simple. Thanks very much for your help on this one

    Chris Hirst
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.