Neat hack to <r:gallery>
I just made a little tweak to the gallery_tags.rb from the Gallery Extension.
It makes it easy to show a gallery somewhere on any page, if that page has a base gallery set. You can also hide a potential surrounding div if it is not needed (not containing a gallery). For example:
<r:gallery fail_silently="true"><div id="gallery">
<r:gallery:lightbox />
</div></r:gallery>
Without the hack, (and the fail_silently attribute) you would get a nasty "undefined method `items' for nil:NilClass" if there was no base gallery set on that page. Of course, it would also work if you are specifying a gallery by name or id, instead of relying on a base gallery being set.
And all it took was;
tag "gallery" do |tag| tag.locals.gallery = find_gallery(tag)
- tag.expand
+ tag.expand unless tag.locals.gallery.nil? && tag.attr['fail_silently']
end
In a reading mood?
About this article
You’re reading an entry titled “Neat hack to <r:gallery>”. Written 5 months ago (08/10/2009) — and archived under gallery. So far, 0 people (dis)agreed with me, what do you think?
About me
I'm Benny Degezelle, a 26 year-old dude from Ghent, Belgium. I'm self employed, being one half of Gorilla webdesign.
I ♥ music, my job, card-playing evenings or party nights with friends and clean code.
Fellow geeks can link up with me on linkedin, ladies and friends may stalk me on Facebook.
What the fuzz is all about
- 2 pages are tagged with WYM
- 1 page is tagged with absolute-urls
- 1 page is tagged with assets
- 2 pages are tagged with documentation
- 2 pages are tagged with editor
- 2 pages are tagged with extension
- 2 pages are tagged with extensions
- 1 page is tagged with page_attachments
- 1 page is tagged with pagination
- 9 pages are tagged with radiant
- 3 pages are tagged with rails
- 2 pages are tagged with ruby
- 2 pages are tagged with shell
- 1 page is tagged with terminal
- 2 pages are tagged with troubleshooting
Github activity
- jomz pushed to master at jomz/radiant-ck_editor_filter-extension
- jomz pushed to master at jomz/radiant-ck_editor_filter-extension
- jomz created branch master at jomz/radiant-ck_editor_filter-extension
- jomz created repository radiant-ck_editor_filter-extension
- jomz forked djcp/radiant-fckeditor