• First of all thank you for the great plugin!

    I would like the user to be able to choose the time scope instead of using search on the events page. There shall be scopes like “today”, “tomorrow”, “this weekend”, “this week”.

    Example: https://london.lecool.com/london/en/weekend
    You can choose what events to display depanding on the time span: today, weekend, this week.

    Is there an easy way I can add such filter option to the events page?

    Thank you.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter ninetienne

    (@ninetienne)

    Thank you for your quick response!

    Luckily I managed to implement the filter. Here’s the code, in case anyone will need it:

    <!-- START Time Scope -->
    		<?php foreach( em_get_scopes() as $key => $value) : ?>
    		<label><input type="radio" name="scope" value='<?php echo $key ?>' /><?php echo $value; ?></label>
    		<?php endforeach; ?>
            <!-- END Time Scope -->
            <hr style="float: left; clear: both; width: 100%; color: #666; margin: 10px 0;" noshade="noshade"/>
    		<!-- START Category Search -->
    		<label><input name="category" type="radio" value="" />Все</label>
            <?php foreach(EM_Categories::get(array('orderby'=>'category_name')) as $EM_Category): ?>
    		<label><input name="category" type="radio" value="<?php echo $EM_Category->id; ?>" /><?php echo $EM_Category->name; ?></label>
    		<?php endforeach; ?>
    		<!-- END Category Search -->
    Thread Starter ninetienne

    (@ninetienne)

    One note though:

    How can I make the radio boxes “checked” on the results page?

    try this:

    echo (condition) ? 'checked="checked"':''

    Thread Starter ninetienne

    (@ninetienne)

    I added the code and now I have:
    <label><input type="radio" name="scope" value='<?php echo $key ?>' <?php echo (condition) ? 'checked="checked"':'' ?>/><?php echo $value; ?></label>
    However the checked radio is always the last one, no matter what I select. Shall I change condition to something else?

    yes. change the condition based on the criteria you wanted like
    example:

    echo ($category_name == 'Rock') ? 'checked="checked"': '' ;
    |_____________________________________________| |_|
    if else

    Thread Starter ninetienne

    (@ninetienne)

    Thank you for trying to help me.

    However I am not aware of the condition for the active category or time scope.

    I would like to user to:

    1. land on the main events page
    2. check the desired filter options by clicking on radio buttons
    3. land on the results page with those filter options checked which the client selected one step ealier.

    Could you please give a hint how it can be done. Many thanks!

    Thread Starter ninetienne

    (@ninetienne)

    OK, I managed to get it for categories.

    Thank you very much!

    Here’s the code:

    <label><input name="category" type="radio" value="" <?php echo (empty($_REQUEST['category'])) ? 'checked="checked"':''; ?>/>Все</label>
            <?php foreach(EM_Categories::get(array('orderby'=>'category_name')) as $EM_Category): ?>
    		<label><input name="category" type="radio" value="<?php echo $EM_Category->id; ?>" <?php echo (!empty($_REQUEST['category']) && $_REQUEST['category'] == $EM_Category->id) ? 'checked="checked"':''; ?>/><?php echo $EM_Category->name; ?></label>
    		<?php endforeach; ?>

    However I can not get it for the time scope with the code:

    <?php foreach( em_get_scopes() as $key => $value) : ?>
    		<label><input type="radio" name="scope" value='<?php echo $key ?>' <?php echo (!empty($_REQUEST['scope']) && $_REQUEST['scope'] == $EM_Scope->id) ? 'checked="checked"':''; ?>/><?php echo $value; ?></label>
    		<?php endforeach; ?>

    I assume there is no $EM_Scope->id.

    What is wrong with my code?

    EM has alot of shortcodes which maybe you can use

    Thread Starter ninetienne

    (@ninetienne)

    I’m not getting too far.

    In your basic installation when you choose start and end date for the search form — the fields are blank on the results page.

    However – from the usability point of view – they shall not be empty! The user shall see what dates apply to the list of given events.

    How can you display the actual dates on the results page?

    @ the events-manager plugin folder there’s a template folder which you can copy at your theme folder like mytheme->plugins(add this folder if not existing)->events-manager->templates

    then you can modify EM looks like events-search..

    for full info. visit https://wp-events-plugin.com/documentation/using-template-files/

    for the date @ search page you can add php date format yyyy-m-d

    add that php date to the events-search at template line

    <input type="text" id="em-date-start-loc"  value="current_date_here" />
    or
    <input type="text" id="em-date-end-loc"  value="current_date_here" />
    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    angelo’s last suggestion is correct, you need to use template files so it’s upgrade safe and modify the search form to your needs. You can feed a select box with name scope instead of the dates and that’d be like using search arguments to feed a scope name e.g. today/tomorrow etc.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Switch between time scopes’ is closed to new replies.