7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Exlude Default Album from Album list
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 634 Views |
-
Exlude Default Album from Album list

18 April 2010 at 1:37am
I've built a global menu for a new site that uses a separate unordered list for each top level section. So that I can have multiple albums per subject matter I have a top level container page called Gallery that holds 6 actual imgage_gallery galler pages, with each of these having X number of albums. The menu code I have that works ok so far is:
<ul class="topNav">
<li class="sub-li"><a class="sub-a" href="/gallery">Gallery</a>
<ul>
<% control ChildrenOf(gallery) %>
<li class="sub-li"><a class="sub-a" href="$Link">$MenuTitle</a>
<% if Albums %>
<ul class="fly">
<% control Albums %>
<li><a href="$Link">$AlbumName</a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>
</li>
</ul>Now at the moment this displays a nice drop-down from Gallery of my 6 gallery pages. But of course the flyout level 3 is displaying 'Default Album' for each gallery. Is there some IF condition I can place in the <% control Albums %> loop to only output a list item if the album name is not 'Default Album'? I'm sure this can be done I'm just struggling with the syntax. Can anyone help?
Thanks
-
Re: Exlude Default Album from Album list

20 April 2010 at 9:12am Last edited: 20 April 2010 9:16am
Well that was a non starter. Trying a different approach now, and that's to require that the Default Album in each gallery is given the same name as the Gallery holder page itself. So now I need something as simple as:
<ul class="topNav">
<li class="top p3"><a id="clients" class="top_link" href="/gallery">Gallery</a>
<% if ChildrenOf(gallery) %>
<ul class="sub">
<% control ChildrenOf(gallery) %>
<li><a href="$Link" class="fly">$MenuTitle</a>
<% if Albums %>
<ul>
<% control Albums %>
<% if AlbumName != MenuTitle %>
<li><a href="$Link">$AlbumName</a></li>
<% end_if %>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>
<% end_if %>
</li>
</ul>Why does that bottom level comparison not work? I've spent over an hour searching for examples of anything similar on these forums but with no luck. Why is $Menutitle not available for a comparison with $AlbumName within this control loop?
Any pointers would be appreciated.
Thanks
-
Re: Exlude Default Album from Album list

20 April 2010 at 9:22am
You can't compare variables in SSViewer. Only literals.
You could probably decorate your ImageGalleryAlbum class to have the function:
public function IsDefault()
{
return $this->owner->AlbumName == $this->owner->ImageGalleryPage()->Title;
}... or just decorate it to have a checkbox for "Default" and then you don't have to deal with arbitrary naming conventions..
-
Re: Exlude Default Album from Album list

20 April 2010 at 10:26am Last edited: 20 April 2010 10:28am
Well the first option seems the least complicated, but I'm just not getting how to do this...
I'ved created:
class MyImageGalleryAlbum extends ImageGalleryAlbum
{
public function IsNotDefaultAlbum()
{
return $this->owner->AlbumName != $this->owner->ImageGalleryPage()->Title;
}
}I'm guessing that's incorrect?
Note: I reversed condition as I can't seem to specify <% if Not(IsDefaultAlbum) %> or anything similar
-
Re: Exlude Default Album from Album list

20 April 2010 at 11:31am
Oh, ok, if you want to do it with a subclass, you can do that, too. Just make sure you subclass your imagegallery page, too, and add
protected $albumClass = "YourAlbumClass";
otherwise, it's
YourAlbum extends DataObjectDecorator
and DataObject::add_extension("ImageGalleryAlbum","YourAlbum");
in your config somewhere..
| 634 Views | ||
|
Page:
1
|
Go to Top |

