/** * Find Skyscraper pages using criteria from the given selector string. * * Serves as a front-end to $pages->find(), filling in some of the redundant * functionality used by multiple template files. * * @param string $selector * @return PageArray * */ function findSkyscrapers($selector) { $validSorts = getValidSkyscraperSorts(); // check if there is a valid 'sort' var in the GET variables $sort = wire('sanitizer')->name(wire('input')->get->sort); // if no valid sort, then use 'title' as a default if (!$sort || !isset($validSorts[ltrim($sort, '-')])) { $sort = 'title'; } // whitelist the sort value so that it is retained in pagination if ($sort != 'title') { wire('input')->whitelist('sort', $sort); } // expand on the provided selector to limit it to 10 sorted skyscrapers $selector = "template=skyscraper, limit=10, " . trim($selector, ", "); // check if there are any keyword searches in the selector by looking for the presence of // ~= operator. if present, then omit the 'sort' param, since ProcessWire sorts by // relevance when no sort specified. if (strpos($selector, "~=") === false) { $selector .= ", sort={$sort}"; } // now call upon ProcessWire to find the skyscrapers for us $skyscrapers = wire('pages')->find($selector); // save skyscrapers for possible display in a map mapSkyscrapers($skyscrapers); // set this runtime variable to the page so we can show the user what selector was used // to find the skyscrapers. the renderSkyscraperList function looks for it. wire('page')->set('skyscraper_selector', $selector); return $skyscrapers; }
, <?php echo $lng; ?> ); $("#content").addClass('has_map'); <?php if ($page->template == 'skyscraper') { $markers = new PageArray(); $markers->add($page); } else { if ($page->template == 'cities' || $page->template == 'home') { $markers = $pages->get("/cities/")->children(); } else { $markers = mapSkyscrapers(); } } foreach ($markers as $item) { if (!$item->map->lat) { continue; } echo "\n\t\tRCDMap.addMarker('{$item->title}', '{$item->url}', {$item->map->lat}, {$item->map->lng});"; } ?> }); </script>
// if the page has a parent, then make it a section label/link in the top right corner if ($page->parent->id) { echo "<p id='parent_label'><a href='{$page->parent->url}'>{$page->parent->title}</a>"; } ?> </div> <div id="content"> <?php echo $content; include "./includes/search_form.php"; include "./includes/sidebar_links.php"; // determine whether we are going to display a map on this page if ($page->map && $page->map->lat || in_array($page->template->name, array('cities', 'home')) || count(mapSkyscrapers())) { include "./includes/map.php"; } ?> </div><!--/content--> </div><!--/container--> <div id='footer'> <div class='container'> <p id='copyright'> <?php if ($config->httpHost == 'processwire.com') { ?>