Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function allTags() {
- global $__CMS_CONN__;
- $sql = 'SELECT name FROM '.TABLE_PREFIX.'tag';
- $arr = array();
- $stmt = $__CMS_CONN__->prepare($sql);
- $stmt->execute();
- while ($obj = $stmt->fetchObject())
- array_push($arr, $obj->name);
- return $arr;
- }
- print_r(allTags());
- // echo allTags();
- ?>
- <?php foreach (allTags() as $tag) : ?>
- <?php $findTag = $tag; // REPLACE hello WITH THE TAG YOU WANT TO FIND ?>
- <h3>Pages with the tag "<?php echo $findTag; ?>":</h3>
- <ul>
- <?php foreach ($this->find('articles')->children() as $child): ?>
- <?php $childTags = join(',', $child->tags()); ?>
- <?php if (preg_match("/\b".$findTag."\b/i", $childTags)) : ?>
- <li><?php echo $child->link(); ?></li>
- <?php endif; ?>
- <?php endforeach; ?>
- </ul>
- <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement