Best approach to a developing problem? (Custom autonav?)

Permalink
Hello! I'm currently developing a site for a photographer, and am in need of some advice. This is only my second C5 site, so I'm still pretty unfamiliar with this (so far wonderful!) CMS.

Problem:
I had an idea for a custom autonav -- closest description I can come up with -- that would incorporate images. It would work like so: Autonav is generated and styled into horizontal layout. Beneath the links, there would be a place for images. When a user rolls over a nav link, a new image scrolls into view. Each link on the autonav would have a particular image assigned to it, so that the same image would always come up for each nav item. However, those images should be editable, in the same way that you can edit the images for a slideshow block.

I *think* I'll need a custom block type for this based on the autonav block; I'm not really sure if that's necessary, or if I can simply communicate with the autonav block in some way (ex: find out how many items are in the autonav via a function).

megntuck
 
johndorsay replied on at Permalink Best Answer Reply
johndorsay
Here's how I would accomplish this

1. Create a new page attribute named 'nav_image'

2. Navigate to each page and add the image to the attribute found in the properties - custom attributes

3. Create a new autonav template based and drop this in at line 33. This will retrieve the file associated to teh nav_image attribute while you are iterating through the array on links

$lfb = LibraryFileBlockController::getFile($c->getAttribute('nav_image')->fID); 
         $navImage = $lfb->getURL();


A few lines lower you should see this code and here is where you'll be adding in the image

if ($c->getCollectionID() == $_c->getCollectionID()) { 
     echo('<a class="nav-selected" href="' . $pageLink . '">' . $ni->getName() . '</a>');
     //echo your image here
     echo '<div class="navigationImage">' . $navImage . '</div>';
} else {
     echo('<a href="' . $pageLink . '">' . $ni->getName() . '</a>');
          echo '<div class="navigationImage">' . $navImage . '</div>';
}


4. Assign the custom template to the nav block.

Now just play with some javascript and you should be ready to go.
megntuck replied on at Permalink Reply
megntuck
Thank you! I hadn't really thought about attributes yet.

This definitely seems like a workable solution. I'll try coding this and see if it will function as desired.
megntuck replied on at Permalink Reply
megntuck
Ran into a problem. I have an external link in the autonav to a blog, and I can't assign it an attribute. The link to galleries may also turn out to be external as well.
johndorsay replied on at Permalink Reply
johndorsay
I handle that is the same sort of way,
Create an attribute named external_link and then add this code to your autonav custom template right underneath this line

if (!$pageLink) {
  $pageLink = $ni->getURL();
}


Add this:
$externalLink = $_c->getAttribute('external_link');
if ($externalLink == true) {
  $pageLink = $externalLink;   
}


This will override the internal link to anywhere you want.

Hope this helps
megntuck replied on at Permalink Reply
megntuck
That solved my problem! It works as desired now.

The only change I had to make to get things working was in the LibraryFileBlockController bit. $c needed to be $_c for my purposes.

Thanks very much!