Customizing The Client-Side Look and FeelCSS and LayoutsSubstruct doesn't ship with templates because customizing the look and feel is very simple. You should never edit anything in the vendor/plugins/substruct directory Here are the steps you should take if you wish to customize the look and feel of Substruct - COPY the css files from /vendor/plugins/substruct/assets/stylesheets into public/stylesheets
- COPY layouts from /vendor/plugins/substruct/app/views/layouts into app/views/layouts
- MODIFY the copied layouts to include your new stylesheets copied in step 1.
- (Make sure to point the CSS include tags to your new files using stylesheet_link_tag, not the engine one!)
- Edit your CSS files all day, and enjoy life.
ViewsCopy anything out of the vendor/plugins/substruct/app/views folder with the same name and folder structure (/content_nodes, /store, etc) into your app/views folder. For instance, if you wished to modify the store index file, you would do the following...
cd my_rails_app
mkdir -p app/views/store
cp vendor/plugins/substruct/app/views/store/index.rhtml app/views/store
This template will be used instead of the default one Substruct uses. Customizing CodeControllersIf you wish to add your own methods to the controllers inside Substruct, or perhaps modify the code that exists there for a custom modification, follow a similar process to customizing views. In this example, let's assume we'd like to add something to the StoreController
cd my_rails_app
touch app/controllers/store_controller.rb
The contents of your new file would look something along these lines...
class StoreController < ApplicationController
# Any methods defined here overwrite the ones in the engines controller file.
end
Working in this way allows you to update the base Substruct code at any given time without disrupting custom modifications you've made. Any new controllers should be placed in your app/controllers directory as well. ModelsModels are a little bit different, in that they require some tweaking to the copied file - but it's still a simple process. Let's assume we'd like to add some new methods to the Order model.
cd my_rails_app
touch app/models/order.rb
The contents of this new order.rb file would look something like this...
require_dependency RAILS_ROOT + "/vendor/plugins/substruct/app/models/order"
class Order < ActiveRecord::Base
# Define your methods here
end
Notice the first line...Rails Engines doesn't automatically know how to deal with extending model files, so we must require the proper model that we're extending. You will of course, need to modify this based on whatever model you are extending. Any new models should be placed in your app/models directory as well.
|
Yeah still not getting how to attach the style sheets im sorry, i took out the plugin parts but i dont understand how to point to the new style sheets? ../public/stylesheets.. or something of that nature? and where do i put that? Thanks for the patience!
Grahamcss... make sure you modify the layout as well... that might be why your not seeing your custom css.
Hrm...maybe I need to make a rake task that copies layouts and prepares them for customization?
Got it figured out ! Now I just need to figure out how to make my "add to cart" do what the demos does. I love css http://lightupgarters.hopto.org
To override things in on Modules like vendor/plugins/substruct/app/controllers/order_helper.rb, you need to use the same style 'require_dependency" as when overriding models.
(Make sure to point the CSS include tags to your new files using stylesheet_link_tag, not the engine one!)
--this means go to your layouts that you just copied over and get rid of anything that says :plugin => substruct (just delete that part).
To customize images substruct uses, you'll either need to edit the ones that were auto copied to public/plugin_assets/substruct... or copy them from that directory to a new location in your public folder and have your .css files point to those new ones that you just copied somewhere else.
With regard to models, in reality you can just copy the model to your app/models directory and edit it there and it will replace the substruct one.
If, however, you want to ADD a single function to your controller or helper extend it--not replace it?, you must use the 'require_dependency' thing mentioned.
note that you can get some leverage by just creating filters for existing controller actions:
http://api.rubyonrails.com/classes/ActionController/Filters/ClassMethods.htmlto charles: the word 'substruct' is a preference in the admin interface, and if you want the right gifs you'll need to go in to where they're referenced and take out the :plugin => substruct that's there.
I suppose a rake task that takes out all :plugin references might be useful :) Also it might be good to note in the 'views' section that you may want to take out some references within the view to :plugin
I probably should have updated my rant. I got the names to replace by modifying the existing layout in place and then restarting mongrel (a restart is required). I haven't tried copying the layouts then modifying them since I don't want to screw up what's already working :) Also, it should be known that changing the substruct name in admin does NOT change the title of pages--all that information is hard coded into the layout.
I was able to update the logo.gif by replacing the originals. However, I'm still getting that weird spacing/alignment issue with logo.gif. It sits on the left, but puts a huge space between the navbar and the search box.
ok, having some difficulty with substruct and CSS/layouts. i'm hosting on hostingrails, which has been great, except with substruct. when i update a CSS file or layout, such as a simple color of a font, for a page that's using a custom CSS file (located in my regular app's stylesheets folder, of course), it's almost as if substruct doesn't recognize the change. i've restarted the rails app on the server and it won't recognize the change. when i "view source", the <head> tag doesn't even specify the CSS files i'm using, but mentions some substruct.css file.
now i will mention, this works perfectly on my machine running my own mongrel server, but on hostingrails using Fast CGI it doesn't work.
it seems as if substruct somehow recompiles layouts and CSS files when it starts or something, and doesn't recognize changes unless it shuts down. does any of this make sense? because it's really annoying me.
to ryandmartin: if you edit it within the public/plugin_assets folder then it might get overwritten on the server you could hard copy it over to make sure it doesn't do that?. I think you're right about the cacheing, though--I'd say take out all the references to caches in substructs views.
The philosophy behind this is quite good, a rake task for this, however is very welcome. A perfect opportunity for me to dive right into rake.
Is no-one else confused by the fact the default welcome page says:-
"Substruct ships with a variety of templates. You'll probably want to use these as a base for your own custom ones." (yes please, that would be great)
...while this page says:-
"Substruct doesn't ship with templates because customizing the look and feel is very simple."
Which is right? Does it ship with templates or not? I'm guessing not, in which case, can they be downloaded? Or is 'variety of templates' simply a reference to the default images and stylesheets in vendor/.../assets?
Any sort of template, even bad ones, would be useful, just to get a clearer visual idea of how the normal layouts, partials etc were intended to fit together. Know the rules before breaking them and all that.
How can I add my own routes to the routes.rb file. Let's say I want to add a new controller to the admin area. How should the route look like??
Please a little help. I am an old C++ programmer not a Css programmer. All I need to do to show this to a client is to replace the Substruct.gif with a customized Store name image. That can't be very difficult, but I'm not able to follow the elliptical comments above. And none of the example websites appear to be using the style_link_tag rails call. Any idea why that is? Specifically, what should each .rhtml file contain in lieu of the following:
Never mind the previous comment. I've got a bit of studying to do.
is the interface supposed to look like a cached page? because there aren't any graphics on mine, and it is all black and white. is it supposed to be like this?