• Replace the code that is in the ‘legend.php’ in the ‘views’ folder of this plugin with the code here.

    What this does is it checks to see what view you are currently in (list view for example) and makes sure to append that view type onto the category legend links so that when you click them you see the category within the appropriate view and aren’t suddenly thrust back into the default view.

    Enjoy!

    <div id="legend_box" class="tribe-events-calendar">
    
        <ul id="legend">
            <?php foreach ( $teccc->terms as $id => $attributes ): ?>
                <?php
    				$slug = esc_attr($attributes[Tribe_Events_Category_Colors::SLUG]);
    				$name = esc_attr($attributes[Tribe_Events_Category_Colors::NAME]);
    				$link = get_term_link($id, TribeEvents::TAXONOMY);
                ?>
                <li class="tribe-events-category-<?php echo $slug ?> tribe-events-category-<?php esc_attr_e($id) ?>">
                    <a href="
    					<?php
    						if( tribe_is_map()) {
    							echo $link, "map";}
    						else if( tribe_is_month()) {
    							echo $link, "month";}
    						else if( tribe_is_upcoming()) {
    							echo $link, "upcoming";}
    						else if( tribe_is_week()) {
    							echo $link, "week";}
    						else if( tribe_is_day()) {
    							echo $link, "day";}
    						else if( tribe_is_photo()) {
    							echo $link, "photo";}
    						else if( tribe_is_venue()) {
    							echo $link, "venue";}
    						else
    							echo $link;
    					?>
    				">
                    	<?php echo $name ?>
                    </a>
                    <input type="hidden" value="<?php echo $slug ?>" />
                </li>
    
            <?php endforeach;?>
    
        </ul>
    
    </div>

    https://www.ads-software.com/plugins/the-events-calendar-category-colors/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andy Fragen

    (@afragen)

    Give me a chance to look closer at this. Thanks.

    Thread Starter skyfox2k

    (@skyfox2k)

    This should fix any issues with empty searches losing the selected view.

    <div id="legend_box" class="tribe-events-calendar">
    
        <ul id="legend">
            <?php foreach ( $teccc->terms as $id => $attributes ): ?>
                <?php
    				$slug = esc_attr($attributes[Tribe_Events_Category_Colors::SLUG]);
    				$name = esc_attr($attributes[Tribe_Events_Category_Colors::NAME]);
    				$link = get_term_link($id, TribeEvents::TAXONOMY);
                ?>
                <li class="tribe-events-category-<?php echo $slug ?> tribe-events-category-<?php esc_attr_e($id) ?>">
                    <a href="
    					<?php
    						$prevPageView = $_SERVER['HTTP_REFERER'];
    						preg_match("/(map|month|upcoming|week|day|photo|week)/", $prevPageView, $matches);
    						if( tribe_is_map()) {
    							echo $link, "map";}
    						else if( tribe_is_month()) {
    							echo $link, "month";}
    						else if( tribe_is_upcoming()) {
    							echo $link, "upcoming";}
    						else if( tribe_is_week()) {
    							echo $link, "week";}
    						else if( tribe_is_day()) {
    							echo $link, "day";}
    						else if( tribe_is_photo()) {
    							echo $link, "photo";}
    						else if( tribe_is_venue()) {
    							echo $link, "venue";}
    						else
    							echo $link .$matches[0];
    					?>
    				">
                    	<?php echo $name ?>
                    </a>
                    <input type="hidden" value="<?php echo $slug ?>" />
                </li>
    
            <?php endforeach;?>
    
        </ul>
    
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use this code to make the legend not lose what view you were on!’ is closed to new replies.