Extends r:find to also allow an 'id' attribute to find with.
Ruby HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app/views/admin/pages
lib
README.md
Rakefile
cucumber.yml
find_by_id_tag_extension.rb
radiant-find_by_id_tag-extension-1.0.0.gem
radiant-find_by_id_tag-extension.gemspec

README.md

Find By Id Tag

This Radiant CMS extension allows you to use r:find with an 'id' attribute instead of the usual 'path' attribute. This way the r:find tag will stay intact even if the path of the target page changes. An 'ids' attribute was also added to r:aggregate to use instead of 'paths'.

Important benefit is that this is also much faster than finding a page by path;

>> Benchmark.measure { Page.find(2546) }
=>   0.000000   0.000000   0.000000 (  0.003986)

>> Benchmark.measure { Page.find_by_path('/farm-forestry-model/species/eucalypts/growing-eucalypts-for-timber---videos-and-information/videos/') }
=>   0.020000   0.010000   0.030000 (  0.027044)

In order to be 'newbie friendly', this extension also allows you to display the page IDs on admin/pages#index and/or admin/pages#edit. In order to do so, set Radiant::Config['expose_page_ids'] to any of 'overview', 'detail' or 'both'. Any other value will hide the ID partials.

There is also a new tag r:id which allows you to render a page's id on the front-end.

Created by Benny Degezelle for nzffa.org.nz