Re: [Radiant] What does Admin::ResourceController do?
replace admin.page.edit.add(:form, mediamaid_gallery, :before= edit_page_parts) with admin.page.edit.add(:form, header, :before= edit_page_parts) (the name of the partial file without the underscore, or .rb) On Sat, Feb 6, 2010 at 11:17 AM, banane ban...@gmail.com wrote: Hi Christian Not sure quite what your objective is, but a couple things I'm thinking while looking at your code: - the usual thing to do for extensions is not to edit the gem code, but make an extension directory (/vendor/extensions/your_extension) and in that file directory structure, include files that will extend the Radiant code base. So to add to the Admin UI, as I think you want to do, you'd add a haml file in /vendor/extensions/your_extension/app/views/admin/_header.html.haml, and then in the Ruby file that is your extension (/vendor/extensions/your_extension/your_extension.rb) you'd include a line of code that would tell the rendering view for the Radiant admin to include your partial: admin.page.edit.add(:form, mediamaid_gallery, :before= edit_page_parts) This page on the wiki really explains well how to change the Admin UI: http://wiki.github.com/radiant/radiant/modifying-the-page-ui Also, getting started on extensions (written by moi) with a focus on converting ruby apps to Radiant extensions, may explain some of hte basic architecture. http://wiki.github.com/radiant/radiant/how-to-create-an-extension On Sat, Feb 6, 2010 at 8:18 AM, Christian Aust christian.a...@software-consultant.net wrote: Hi all, I'm writing an extension to Radiant that defines new database entities. The docs suggest to let my controller inherit from Admin::ResourceController, to get a lot of functionality for free. What is that functionality, specifically? In particular, I've been confused by that :singular and :plural stuff in there, what's that? When do I need that? What's going on with the @template_name and @controller_name variables, what do I need them for? As I've mentioned before, Radiant itself is pretty neat, but documentation on these parts of its public API isn't only lacking but non-existant. That makes it harder to understand errors like this: My entity is called City, I've copied all relevant code from Radiants Page view and controller. The edit haml throws this error: undefined method `cities' for #Radiant::AdminUI:0x102036be8 Extracted source (around line #1): 1: - render_region :main do |main| 2: - main.edit_header do 3: %h1 Edit City 4: - main.edit_form do /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in `send' /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in `lazy_initialize_region_set' /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:3:in `render_region' /Users/christian/mueller/vendor/extensions/mueller/app/views/admin/cities/edit.html.haml:1:in `_run_haml_vendor47extensions47mueller47app47views47admin47cities47edit46html46haml' It feels like I've got something wrong while copying code, but I can't easily tell what. Can you? Kind regards, Christian ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ List Site: http://lists.radiantcms.org/mailman/listinfo/radiant Radiant: http://radiantcms.org Extensions: http://ext.radiantcms.org ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ List Site: http://lists.radiantcms.org/mailman/listinfo/radiant Radiant: http://radiantcms.org Extensions: http://ext.radiantcms.org
Re: [Radiant] Radiant Digest, Vol 47, Issue 11
Christian, Admin::ResourceController gives you CRUD methods so you don't have to define them yourself. Methods like :index, :edit, :update, :new, :create, :delete are built in. So on a plugin I am working on I only define the show method (controller for a podcast's Shows) to get a single 'Show' in my podcast... class Admin::ShowsController Admin::ResourceController model_class Show before_filter :find_model, :only = [ :show ] def show respond_to do |format| format.html # show.html.erb format.xml { render :xml = @show } end end private def find_model @show = Show.find(params[:id]) if params[:id] end end Regards, -Bill pixelhandler On Feb 6, 2010, at 10:00 AM, radiant-requ...@radiantcms.org wrote: Message: 1 Date: Sat, 6 Feb 2010 17:18:34 +0100 From: Christian Aust christian.a...@software-consultant.net Subject: [Radiant] What does Admin::ResourceController do? To: radiant@radiantcms.org Message-ID: 3b13c44e-4d65-48f1-a610-c457823a0...@software-consultant.net Content-Type: text/plain; charset=us-ascii Hi all, I'm writing an extension to Radiant that defines new database entities. The docs suggest to let my controller inherit from Admin::ResourceController, to get a lot of functionality for free. What is that functionality, specifically? In particular, I've been confused by that :singular and :plural stuff in there, what's that? When do I need that? What's going on with the @template_name and @controller_name variables, what do I need them for? As I've mentioned before, Radiant itself is pretty neat, but documentation on these parts of its public API isn't only lacking but non-existant. That makes it harder to understand errors like this: My entity is called City, I've copied all relevant code from Radiants Page view and controller. The edit haml throws this error: undefined method `cities' for #Radiant::AdminUI:0x102036be8 Extracted source (around line #1): 1: - render_region :main do |main| 2: - main.edit_header do 3: %h1 Edit City 4: - main.edit_form do /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in `send' /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in `lazy_initialize_region_set' /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:3:in `render_region' /Users/christian/mueller/vendor/extensions/mueller/app/views/admin/cities/edit.html.haml:1:in `_run_haml_vendor47extensions47mueller47app47views47admin47cities47edit46html46haml' It feels like I've got something wrong while copying code, but I can't easily tell what. Can you? Kind regards, Christian -- ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ List Site: http://lists.radiantcms.org/mailman/listinfo/radiant Radiant: http://radiantcms.org Extensions: http://ext.radiantcms.org
Re: [Radiant] What does Admin::ResourceController do?
Hi banane, my code is packaged as an extension, however I stepped through the code of radiant to see how things worked there. Eventually, I followed this tutorial: http://wiki.github.com/radiant/radiant/creating-a-link-roll-extension http://wiki.github.com/radiant/radiant/removing-the-scaffold-from-the-link-roll-extension I created a new database entity that doesn't depend on radiants Page class, but is similar to it in some regards. There's a new UI in the admin section to work with that entity, plus a number of radius tags that make it available to Radiant pages. Regards, Christian ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ List Site: http://lists.radiantcms.org/mailman/listinfo/radiant Radiant: http://radiantcms.org Extensions: http://ext.radiantcms.org