We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I added a $twig_var for a HTML-Sitemap with Bootstrap3 Markup und combined the other things from my last Issue #5
$twig_var
<?php /** * Generate an xml sitemap for Pico * * @author Dave Kinsella * @link https://github.com/Techn0tic/Pico_Sitemap * @license http://opensource.org/licenses/MIT */ class Pico_Sitemap { private $is_sitemap; private $is_html_sitemap; private $exclude; private $pages; public function __construct() { $this->is_sitemap = false; $this->is_html_sitemap = false; $this->exclude = array('home', 'slider', 'suche', 'sitemap'); $this->pages = array(); } public function request_url(&$url) { if($url == 'sitemap') $this->is_html_sitemap = true; if($url == 'sitemap.xml') $this->is_sitemap = true; } public function get_pages($pages) { if($this->is_sitemap || $this->is_html_sitemap) { global $config; foreach($pages as $page) { preg_match('/\/('.implode('|', $this->exclude).')\//', $page['url'].'/', $matches); if(empty($matches)) { $index = ''; $date = false; $path = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'content'.DIRECTORY_SEPARATOR.str_ireplace($config['base_url'], '', $page['url']); if(is_dir($path)) { $index = 'index'; } $file = realpath($path.$index.'.md'); if(file_exists($file)) { $date = date ("Y-m-d", filemtime($file)); } array_push($this->pages, array( 'url' => $page['url'], 'title' => $page['title'], 'lastmod' => $date, 'index' => $index == '' ? false : true )); } } sort($this->pages); } } public function before_render(&$twig_vars, &$twig, &$template) { if($this->is_sitemap) { header($_SERVER['SERVER_PROTOCOL'].' 200 OK'); header('Content-Type: application/xml; charset=UTF-8'); $xml = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; foreach($this->pages as $page) { $xml .= '<url><loc>'.$page['url'].'</loc><lastmod>'.$page['lastmod'].'</lastmod></url>'; } $xml .= '</urlset>'; header('Content-Type: text/xml'); die($xml); } elseif($this->is_html_sitemap) { $panel_raw = '<div class="col-md-4"><div class="panel panel-primary"><div class="panel-heading"><h3 class="panel-title"><a href="%url%">%title%</a></h3></div><div class="list-group">%childs%</div></div></div>'; $child_raw = '<a href="%url%" class="list-group-item"><i class="icon-link"></i> %title%</a>'; $panel = ''; $childs = array(); $out = ''; $out .= '<div class="row">'; foreach($this->pages as $page) { if($page['index']) { $panel = str_replace('%childs%', implode('', $childs), $panel); $out .= $panel; $childs = array(); $panel = $panel_raw; $panel = str_replace('%url%', $page['url'], $panel); $panel = str_replace('%title%', $page['title'], $panel); } else { $child = $child_raw; $child = str_replace('%url%', $page['url'], $child); $child = str_replace('%title%', $page['title'], $child); array_push($childs, $child); } } $panel = str_replace('%childs%', implode('', $childs), $panel); $out .= $panel; $out .= '</div>'; $twig_vars['sitemap'] = $out; } } }
The text was updated successfully, but these errors were encountered:
My Gist: https://gist.github.com/Gummibeer/2735309d3012f911962e
Sorry, something went wrong.
No branches or pull requests
I added a
$twig_var
for a HTML-Sitemap with Bootstrap3 Markup und combined the other things from my last Issue #5The text was updated successfully, but these errors were encountered: