Advertising
This is an old thread that I have been meaning to follow up. Sean
suggested:
that one
should focus on the _why_ you need an uncached page in the first
place, and address that need first
Indeed!
I created a route:
map.with_options(:controller => 'site') do |site|
site.connect 'store-directory/:name', :action => 'show_page',
:url => '/store-directory/store'
end
This captures URL's like these:
/store-directory/mcdonoughs-your-independent-grocery
/store-directory/carlton-cards
A better solution would be to create a new model called StorePage,
inheriting from Radiant's Page model. You can override the find_by_url
method, so that the StorePage would behave as an 'index' page, or a
'show' page. For example:
/store-directory
Would be an index page, listing all your stores
/store-directory/mcdonoughs-your-independent-grocery
/store-directory/carlton-cards
These would be 'show' pages, for individual stores.
You would only need to create a single StorePage in your Radiant
sitemap. In the above example, this would have the slug 'store-
directory'. Each of the sub-pages, corresponding to individual Store
models, would exist as 'virtual pages'. You won't see them in the
sitemap of the Radiant admin, but they exist on the public facing site.
If you use this approach, you don't need to create any custom routes.
The index/show pages would both be rendered using the
SiteController#show_page action. This should mean that caching works
just as you would expect. So the /store-directory page and /store-
directory/carlton-cards pages would be cached without interfering with
each other.
Here is an example of a model that overrides the page model:
http://github.com/nelstrom/radiant-movies-extension/blob/97b149f84f75e887dd37261acdee3ebd6570b26c/app/models/movie_page.rb#L5-17
Note the tags: <movies:if_index/> and <movies:unless_index/>. The
content for the index page should go inside the if_index tag, and the
content for the 'show' pages should go inside the unless_index block.
I hope this helps clear things up.
Cheers,
Drew
_______________________________________________
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant