Created
October 27, 2013 03:37
-
-
Save tylerforesthauser/7177720 to your computer and use it in GitHub Desktop.
Used to display current category's immediate parent on Product Listing pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$strC = Yii::app()->getRequest()->getQuery('cat'); | |
$objCategory = Category::LoadByRequestUrl($strC); | |
?> | |
<?= ($objCategory->Parent) ? '<h2>'.$objCategory->Parent->label.'</h2>' : '' ?> |
I've used the following in views/site/main.php
Which would be quicker: querying the database for the category-parent or detecting the category-parent in the slug?
elseif (strpos($catSlug,'outdoor') !== false) {
echo '<div id="outdoor-header"><h1 class="category-heading">' . $this->pageHeader . '</h1></div>';
echo '<div class="sub-menu-container container">';
echo wp_nav_menu( array( 'theme_location' => 'ooutdoor_nav', 'menu_class' => 'sub-category-nav visible-desktop' ) );
echo '</div>';
} else {
echo '<div id="default-header" class="pageheader"><h1 class="category-heading">' . $this->pageHeader . '</h1></div>';
echo '<div class="sub-menu-container container">';
echo wp_nav_menu( array( 'theme_location' => 'living_room_nav', 'menu_class' => 'sub-category-nav visible-desktop' ) );
echo '</div>';
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For use in the
/search/grid.php
view.