Thanks, have spent this morning trying to get this to work but I'm just not managing it unfortunately.
I've gone down the include route so that now, my event index page looks like this:
<?php include("./header.inc"); ?>
<?php if ($input->urlSegment1 != "") {
include ("./categories.inc");
} else { ?>
<div id="events_index_wrap" class="bg_gradient">
<div id="events_index_main">
<h3 class="page_header">Upcoming Events</h3>
<?php
$entries = $pages->find("template=event, sort=date");
$count = 0;
foreach ($entries as $event) {
$count++;
$class = "event_box";
if (0 == $count % 2) { $class .= " event_box_second"; }
?>
<div class="<?php echo $class; ?>">
<div class="event_box_text">
<h2><a href="<?php echo $event->url; ?>"><?php echo $event->title; ?></a></h2>
<h5><?php echo $event->date; ?></h5>
</div><!-- /.event_box_text -->
<div class="clear"></div>
<?php if ($event->images) {
$img = $event->images->first()->size(220,165);
?>
<a href="<?php echo $event->url; ?>"><img src="<?php echo $img->url; ?>" width="<?php echo $img->width; ?>" height="<?php echo $img->height; ?>" alt="<?php echo $entry->title; ?>" class="med_frame" /></a>
<?php } ?>
</div><!-- /.event_box -->
<?php }
?>
</div><!-- /#events_index_main -->
<div id="events_index_side">
<div class="events_index_side_box">
<?php if (count($pages->find("template=category"))) {
$category = $pages->find("template=category");
?>
<ul>
<?php foreach ($category as $cat) { ?>
<li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->name; ?></a></li>
<?php } ?>
<?php } ?>
</div><!-- /.events_index_side_box -->
</div><!-- /#events_index_side -->
<div class="clear"></div>
</div><!-- /#events_index_wrap -->
<?php } ?>
<?php include("./footer.inc"); ?>So on the category list, I tack on the category name to the url and if there's a URL segment it includes the categories include, which looks like:
<div id="events_index_wrap" class="bg_gradient">
<div id="events_index_main">
<h3 class="page_header">Upcoming Events - <?php echo $input->urlSegment1; ?></h3>
<?php
$name = $sanitizer->pageName($input->urlSegment1);
echo "<h1>$name</h1>";
$entries = $pages->find("template=event, categories=$name, sort=date");
$count = 0;
foreach ($entries as $event) {
$count++;
$class = "event_box";
if (0 == $count % 2) { $class .= " event_box_second"; }
?>
<div class="<?php echo $class; ?>">
<div class="event_box_text">
<h2><a href="<?php echo $event->url; ?>"><?php echo $event->title; ?></a></h2>
<h5><?php echo $event->date; ?></h5>
</div><!-- /.event_box_text -->
<div class="clear"></div>
<?php if ($event->images) {
$img = $event->images->first()->size(220,165);
?>
<a href="<?php echo $event->url; ?>"><img src="<?php echo $img->url; ?>" width="<?php echo $img->width; ?>" height="<?php echo $img->height; ?>" alt="<?php echo $entry->title; ?>" class="med_frame" /></a>
<?php } ?>
<?php $categories = $event->categories; foreach ($categories as $cg) { ?>
<h6><?php echo $cg->name; ?></h6>
<?php } ?>
</div><!-- /.event_box -->
<?php }
?>
</div><!-- /#events_index_main -->
<div id="events_index_side">
<div class="events_index_side_box">
<?php if (count($pages->find("template=category"))) {
$category = $pages->find("template=category");
?>
<ul>
<?php foreach ($category as $cat) { ?>
<li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->name; ?></a></li>
<?php } ?>
<?php } ?>
</div><!-- /.events_index_side_box -->
</div><!-- /#events_index_side -->
<div class="clear"></div>
</div><!-- /#events_index_wrap -->My issue is that I'm pretty sure that the category name is matching the urlSegment but when I choose a category the list comes up empty. I've thought of possible reasons (lower/upper case categories?), I've also tried to pass a variable to the current category but not to sure how to get that working before looping through the entries...
If anyone has any idea, that would be much appreciated, thanks.