Display pages by category/attribute?

Permalink
OK, I have a list of people/biographies I wanna show on a page. The challenge here is that these people belong to different categories and can belong to multiple categories, too. So, on the landing page I’m gonna show all people in the main section and a link list of the available categories in the sidebar (as a sub navigation of the current main navigation), like so:

nav item
another nav item
third nav item
  sub category 1
  sub category 2
  sub category 3
  …
another nav item


When the visitor clicks on one of these category links only the people that belong to this category should be displayed in the main section. What’s the best approach to go about this?

The way I’m thinking it now is that I have a separate page for each person which could get one or more text attributes containing the category they belong to, and then use the page list block to list them. But how am I going to filter that by category/attribute and how am I going to display these categories in the navigation?

View Replies:
TheRealSean replied on at Permalink Reply
TheRealSean
I would add user attributes to those users with the ability to select multiple options, select box.

Then in your member list add either a filter from a $_GET to filter by category, or create a page for each category with the member list on each pre-filtered by that attribute.

You can get a list of the attributes, from the table or as a quick fix hardcode them in.

foreach($c->getCollectionAttributeValue('user_category') as $opt) {
   echo '<li>' . $opt . '<li/>';
}
//from the following //http://www.concrete5.org/community/forums/customizing_c5/getting-attribute-list-in-theme-file/#108961
jordanlev replied on at Permalink Reply
jordanlev
This might be helpful:
http://www.concrete5.org/community/forums/block_requests/content-re...

...or if you don't want to touch code at all there's also a paid marketplace addon that does a similar thing (and is probably a bit more polished than the free one linked to above):
http://www.concrete5.org/marketplace/addons/related-pages/...
jordanlev replied on at Permalink Reply
jordanlev
And if you're a programmer, more details about how to work with these attributes can be found here as well:
http://www.concrete5.org/community/forums/customizing_c5/get-page-t...
http://www.concrete5.org/community/forums/customizing_c5/how-to-wan...
10010110 replied on at Permalink Reply
Thank you, guys, for your quick and numerous replies.

So, I have tried the related content block jordan proposed but it’s only allowing to choose one category to display the content from. What I need is a list of attribute values on the front end where I can click on one of these links and it shows me the pages that belong to that category. And I actually kind of found that with the tag cloud that comes preinstalled, which is the search block with a custom template, using the also preinstalled tag attribute.

This is almost exactly what I need except I need it within my autonav as submenu of the current page. I have to split right now and I’m gonna try to implement the code from the custom search template into my custom autonav template when I’m back. I’d still be happy about any idea or guidance that could be useful for this matter – especially how I would highlight the currently selected attribute/category once it shows the results (like adding a “current” class to the currently selected tag/category).

Thanks!
10010110 replied on at Permalink Reply
OK, I’ve made some progress, even though it’s not quite perfect yet. Unfortunately I can’t show a live version at the moment so I hope you can still help me looking at my code. I have integrated the “tag cloud” search block template into the autonav like this:
<?php 
   defined('C5_EXECUTE') or die("Access Denied.");
   $aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   $containsPages = false;
   $nh = Loader::helper('navigation');
   //this will create an array of parent cIDs 
   $inspectC=$c;
   $selectedPathCIDs=array( $inspectC->getCollectionID() );
   $parentCIDnotZero=true;   
   while($parentCIDnotZero){
      $cParentID=$inspectC->cParentID;
      if(!intval($cParentID)){
         $parentCIDnotZero=false;
      }else{


Now, this is putting the list of tags I have in a sub list. However, the search block allowed to select tags of pages from a certain sub page and to post the results to a certain page, too. Since I’ve hard coded this into the template as you can see here (have a page called “results” and had to remove the “$resultTargetURL” stuff):
<li><a href="<?php /*echo $this->url($resultTargetURL)*/?>results?<?php echo $qs?>">

… this is no longer working. I think it’s not too much of an issue to hard code the results page name into the template but how can I retreive only those tags from the sub pages of the current page?

And how would I make it that a specific “current” class is assigned to the list item that’s currently selected? The results page doesn’t know which tag link has been clicked – hm, but somehow the results page does know which results to display so there must be a way to tell the tag list, too? I’m grateful for any enlightenment. Please.
TheRealSean replied on at Permalink Reply
TheRealSean
You should be within the loop of the page you want to enter the tags for, as these should only be displaying on the page you are on.

Try using this,
<?php echo $nh->getLinkToCollection($pageLink)?>?<?php echo $qs?>">
TheRealSean replied on at Permalink Reply
TheRealSean
To do the preselected you need to pass in your selected querystring you could maybe use, something like the following
//before the loop
$selQs = $_GET['filter'];

if($selQs == $qs)$selClass = " class='selected'";
else $selClass = "";

//within your tal li loop
<li<?php echo $selClass?>><a href="goingSomewhere?">

I have no idea if this is the best way to do it but it can be done within the view to prevent any editing of the controller. Maybe someone else can point a tidier way to do this?
jordanlev replied on at Permalink Reply
jordanlev
I think this is a great way to do it too.