Created
April 29, 2011 13:45
-
-
Save dajare/948315 to your computer and use it in GitHub Desktop.
Tag page code for Wolf CMS plugin Tagger - inserts date values into archive page URLs
This file contains 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 | |
$pages = $this->tagger->pagesByTag(); | |
if($pages){ | |
echo "<h3>Pages tagged with '".$this->tagger->tag()."':</h3>"; | |
echo '<ul>'; | |
foreach($pages as $slug => $page) { | |
// set number in next line to total characters of URL up to first slug: | |
$pageslugs = substr($slug, 28); | |
// if archive page, put date slugs into URI: | |
if ($this->find($pageslugs)->parent()->behavior_id == 'archive') { | |
$slugarray = explode('/', $pageslugs); $starturi = reset($slugarray); $enduri = end($slugarray); | |
$uridate = $this->find($pageslugs)->date('%Y/%m/%d/'); | |
echo '<li><a href="'. URL_PUBLIC . $starturi ."/". $uridate . $enduri . URL_SUFFIX .'">'.$page.'</a> ['. $this->find($pageslugs)->date() .']</li>'; | |
// normal page, so normal URI: | |
} else { | |
echo '<li><a href="'.$slug.'">'.$page.'</a> ['. $this->find($pageslugs)->date() .']</li>'; | |
} | |
} | |
echo '</ul>'; | |
} else { | |
echo "<p>There are no items with this tag.</p>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes:
http://example.com/blog/article
, the number would be 19.$slug
).