<?php
/*
At this point we have...
$site
$navStartNode
$mainNavigation
$menu
*/
use \Pimcore\Navigation\Page;
# RESULT: $this->document
if( !$this->document instanceof \Pimcore\Model\Document\Page ) { // Check if we have a document by default...
if( \Pimcore\Model\Site::isSiteRequest() ) { // Check if the request is a site request...
$site = \Pimcore\Model\Site::getCurrentSite(); // Assign the site root as the current document...
$this->document = $site->getRootDocument();
} else {
$this->document = \Pimcore\Model\Document\Page::getById( 1 ); // Assign the root document as the current document...
}
}
# RESULT: $navStartNode
$navStartNode = $this->document->getProperty( 'navigationRoot' ); // Allow a site manager to define the navigation root with a property...
if( !$navStartNode instanceof \Pimcore\Model\Document\Page ) { // Figure out if the navigation root is a valid document...
if( \Pimcore\Model\Site::isSiteRequest() ) { // Check if the request is a site request...
$site = \Pimcore\Model\Site::getCurrentSite(); // Assign the site root as the navigation root...
$navStartNode = $site->getRootDocument();
} else {
$navStartNode = \Pimcore\Model\Document\Page::getById( 1 ); // Assign the root document as the navigation root...
}
}
// Generate a working site navigation...
$mainNavigation = $this->navigation()->buildNavigation( $this->document, $navStartNode );
?>
<div class="navigation-links-desktop show-for-large">
<?php
// State Abbreviations...
$states = array(
'dc'=>'District of Columbia'
, 'al' => 'Alabama' , 'hi' => 'Hawaii' , 'ma' => 'Massachusetts' , 'nm' => 'New Mexico' , 'sd' => 'South Dakota'
, 'ak' => 'Alaska' , 'id' => 'Idaho' , 'mi' => 'Michigan' , 'ny' => 'New York' , 'tn' => 'Tennessee'
, 'az' => 'Arizona' , 'il' => 'Illinois' , 'mn' => 'Minnesota' , 'nc' => 'North Carolina' , 'tx' => 'Texas'
, 'ar' => 'Arkansas' , 'in' => 'Indiana' , 'ms' => 'Mississippi' , 'nd' => 'North Dakota' , 'ut' => 'Utah'
, 'ca' => 'California' , 'ia' => 'Iowa' , 'mo' => 'Missouri' , 'oh' => 'Ohio' , 'vt' => 'Vermont'
, 'co' => 'Colorado' , 'ks' => 'Kansas' , 'mt' => 'Montana' , 'ok' => 'Oklahoma' , 'va' => 'Virginia'
, 'ct' => 'Connecticut' , 'ky' => 'Kentucky' , 'ne' => 'Nebraska' , 'or' => 'Oregon' , 'wa' => 'Washington'
, 'de' => 'Delaware' , 'la' => 'Louisiana' , 'nv' => 'Nevada' , 'pa' => 'Pennsylvania' , 'wv' => 'West Virginia'
, 'fl' => 'Florida' , 'me' => 'Maine' , 'nh' => 'New Hampshire' , 'ri' => 'Rhode Island' , 'wi' => 'Wisconsin'
, 'ga' => 'Georgia' , 'md' => 'Maryland' , 'nj' => 'New Jersey' , 'sc' => 'South Carolina' , 'wy' => 'Wyoming'
);
// Generate a hierarchy composed of city-to-state relationships...
$Structure = array();
$YardiProperties = new \Pimcore\Model\DataObject\YardiProperty\Listing();
foreach( $YardiProperties as $YardiProperty ) {
// Parse the cached property data...
$YardiPropertyJson = json_decode( $YardiProperty->getCache_property() )[ 0 ];
$PropertyData = $YardiPropertyJson->PropertyData;
// Get key and name pairs...
$PropertyStateKey = \Pimcore\File::getValidFilename( strtolower( $PropertyData->state ) );
$PropertyState = $states[ strtolower( $PropertyStateKey ) ];
$PropertyCityKey = \Pimcore\File::getValidFilename( $PropertyData->city );
$PropertyCity = $PropertyData->city;
// Skip empty-string states and cities...
if( empty( $PropertyStateKey ) || empty( $PropertyCityKey ) ) continue;
// Create the array if it doesn't exist yet...
if( !is_array( $Structure[ $PropertyStateKey ] ) ) {
$Structure[ $PropertyStateKey ] = array();
}
// Assign the name of the city to the tree...
$Structure[ $PropertyStateKey ][ $PropertyCityKey ] = $PropertyCity;
}
$CheckURI = explode( '/', trim( parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH ), '/' ) );
// Turn the hierarchy into navigation links...
$StateLinks = array();
foreach( $Structure as $StateKey => $Cities ) {
$CityLinks = array();
foreach( $Cities as $CityKey => $CityLabel ) {
$CityLinks[] = array(
'uri' => $this->path( 'Properties S_C', [ 'state' => $StateKey, 'city' => $CityKey ] ),
'label' => $CityLabel,
'active' => ( @$CheckURI[ 0 ] == 'apartments' && @$CheckURI[ 1 ] == $StateKey && @$CheckURI[ 2 ] == $CityKey )
);
}
$StateLink = array(
'uri' => $this->path( 'Properties S', [ 'state' => $StateKey ] ),
'label' => $states[ $StateKey ],
'active' => ( @$CheckURI[ 0 ] == 'apartments' && @$CheckURI[ 1 ] == $StateKey )
);
if( !empty( $CityLinks ) ) {
$StateLink[ 'pages' ] = $CityLinks;
}
$StateLinks[] = $StateLink;
}
$ApartmentsLinks = array(
'order' => -1,
'uri' => $this->path( 'Properties', [] ),
'label' => 'Apartments',
'class' => 'mega-menu',
'active' => ( @$CheckURI[ 0 ] == 'apartments' )
);
if( !empty( $StateLinks ) ) {
$ApartmentsLinks[ 'pages' ] = $StateLinks;
}
// Add our group of links to the navigation...
$mainNavigation->addPage( $ApartmentsLinks );
?>
<style type="text/css">
/* Normal Dropdowns */
#theme-header .navigation-links-desktop .navigation > li {
position: relative;
}
#theme-header .navigation-links-desktop .navigation > li > ul {
border-top: 4px solid #e03133;
padding: 0.5rem 0;
background: #efefef;
opacity: 0;
box-shadow: 0px 2px 4px rgba(0,0,0,0.5);
-webkit-transform-origin: 100% 4px;
transform-origin: 100% 4px;
-webkit-transform: scaleY(0);
transform: scaleY(0);
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
transition: transform 0.25s, opacity 0.25s;
position: absolute;
top: 100%;
right: -1.5rem;
}
#theme-header .navigation-links-desktop .navigation > li > ul > li {
white-space: nowrap;
}
#theme-header .navigation-links-desktop .navigation > li > ul > li > a {
display: block;
padding: 0.5rem 1.5rem;
color: #33a5bf;
font-size: 1rem;
line-height: 1;
transition: color 0.5s;
-webkit-transition: color 0.5s;
-ms-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
text-transform: capitalize;
text-align: left;
}
#theme-header .navigation-links-desktop .navigation > li > ul > li > a:hover{
color: #000;
transition: color 0.5s;
-webkit-transition: color 0.5s;
-ms-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
}
#theme-header .navigation-links-desktop .navigation > li:hover > ul {
opacity: 1;
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
/* Mega Dropdowns */
#theme-header .navigation-links-desktop .navigation > li > a.mega-menu + ul {
display: flex;
table-layout: fixed;
text-align: left;
padding: 2rem 3.5rem;
max-width: 1200px;
width: 100%;
box-shadow: none;
-webkit-transform: translate(-50%,0%) scaleY(0);
transform: translate(-50%,0%) scaleY(0);
position: fixed;
top: 74px;
left: 50%;
}
#theme-header .navigation-links-desktop .navigation > li:hover > a.mega-menu + ul {
opacity: 1;
-webkit-transform: translate(-50%,0%) scaleY(1);
transform: translate(-50%,0%) scaleY(1);
border-top: 0;
}
#theme-header .navigation-links-desktop .navigation > li > a.mega-menu + ul::before {
content: "";
background: #efefef;
width: 100vw;
height: 100%;
box-shadow: 0px 2px 4px rgba(0,0,0,0.5);
-webkit-transform: translate(-50%,0%);
transform: translate(-50%,0%);
position: absolute;
z-index: 1;
top: 0;
left: 50%;
border-top: 4px solid #e02e33;
}
#theme-header .navigation-links-desktop .navigation > li > a.mega-menu + ul::after {
content: "";
display: block;
clear: both;
float: none;
height: 0;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li {
display: block;
float: left;
padding: 0 1.5rem;
width: <?= 100 / count( $StateLinks ) ?>%;
position: relative;
z-index: 2;
border-right: 2px solid #e0e0e0;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li:first-child {
padding: 0 1.5rem 0 0;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li:last-child {
border-right: none;
padding: 0 0 0 1.5rem;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li > a {
padding: 0;
font-family: 'BrandonTextWeb-Regular', sans-serif;
font-size: 20px;
text-transform: capitalize;
color: #33a5bf;
margin-bottom: 10px;
-webkit-transition: color 0.5s;
transition: color 0.5s;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li > a:hover {
color: #000;
transition: color 0.5s;
-webkit-transition: color 0.5s;
-ms-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li > ul > li > a {
font-family: 'BrandonTextWeb-Regular', sans-serif;
font-size: 16px;
text-transform: capitalize;
color: #000;
transition: color 0.5s;
-webkit-transition: color 0.5s;
-ms-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li > ul > li > a:hover{
color: #33a5bf;
transition: color 0.5s;
-webkit-transition: color 0.5s;
-ms-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
}
#theme-header .navigation-links-desktop .navigation > li > .mega-menu + ul > li > ul {
column-count: 2;
}
#theme-header .navigation-links-mobile .has-children .menu-wrapper li {
position: relative;
margin-left: 1rem;
}
#theme-header .navigation-links-mobile .has-children .menu-wrapper li a{
color: #33a5bf;
margin-bottom: 1rem;
display: block;
}
#theme-header .navigation-links-mobile .has-children .menu-wrapper li ul li a{
color: #fff;
font-family: 'BrandonTextWeb-Regular', sans-serif;
}
</style>
<?= $this->navigation()->render( $mainNavigation ) ?>
</div>