WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar Category Colors
Use this code to make the legend not lose what view you were on! (3 posts)

  1. skyfox2k
    Member
    Posted 4 months ago #

    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://wordpress.org/plugins/the-events-calendar-category-colors/

  2. Andy Fragen
    Member
    Plugin Author

    Posted 4 months ago #

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

  3. skyfox2k
    Member
    Posted 4 months ago #

    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>

Reply

You must log in to post.

About this Plugin

About this Topic