I'm new to the Rails.
I think this might be a matter of simple code but was hoping someone might
be able to help.
I'm trying to isolate a CATEGORY so that it does not come up in the
SHARED/HEADER but can come up on it's own page.
I have created a page in CATEGORY/issue7.html.haml
and have copied the code to it.
I have all the paths and routes configured and the code from
CATEGORY/CONTROLLER/def show coped into CATEGORY_Controller/def issue7 in
the controller.
But I wasn't sure how to manually tell it to look for a certain category as
opposed to pulling the hash of all categories.
I assume I just need to provide the variable that is passed from the Header
when you hit a category button and it takes you to category show.
And then provide that variable (catergoy.id) for the individual page.
But I can't figure out how to do this.
This is the code from the header (category lists)
#NavBar
%ul
- Category.find(:all).each do |c|
= topnav_tab c.name, {:url => category_path(c), :section => c.name}
= topnav_tab "Community".l, { :url => users_path, :section => 'users'
}
- if current_user
= topnav_tab "My Profile".l, { :url => user_path(current_user),
:section => 'my_profile'}
This is the code for CATEGORY_CONTROLLER for CATEGORY SHOW
def show
@category = Category.find(params[:id])
@sidebar_right = true
cond = Caboose::EZ::Condition.new
cond.category_id == @category.id
order = (params[:popular] ? "view_count #{params[:popular]}":
"published_at DESC")
order = (params[:favorite] ? "favorite_count #{params[:favorite]}":
"published_at DESC")
@pages, @posts = paginate :posts, :order => order, :conditions =>
cond.to_sql, :include => :tags
@recent_posts = @category.posts.find(:all, :limit => 15, :order =>
"view_count DESC")
@popular_posts = @category.posts.find(:all, :limit => 10, :order =>
"view_count DESC")
@popular_polls = Poll.find_popular_in_category(@category)
@rss_title = "#{AppConfig.community_name}: [EMAIL PROTECTED] posts"
@rss_url = formatted_category_path(@category, :rss)
@active_users = User.find(:all,
:include => :posts,
:limit => 20,
:conditions => ["posts.category_id = ? AND posts.published_at > ?", @
category.id, 14.days.ago],
:order => "users.view_count DESC"
)
respond_to do |format|
format.html # show.rhtml
format.rss {
render_rss_feed_for(@posts, {:feed => {:title =>
"#{AppConfig.community_name}: [EMAIL PROTECTED] posts", :link =>
category_url(@category)},
:item => {:title => :title, :link => :link_for_rss, :description
=> :post, :pub_date => :published_at} })
}
end
end
I know this is a lot of writing. I would very much appreciate any help.
Garrett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---