テンプレート表示

前回書いたようなモデル化までが済んでいれば,テンプレートでマルチカテゴリをサポートするのは簡単です。とりあえずテンプレートにと書いたときに展開するというだけのものをあげておきます。これをテンプレートのパースのクラスに置くだけでOKです。

  def parse_multiplecategories params
    temp = ""
    separator = nil
    item.categories.each do |cat|
      temp += separator.to_s
      separator ||= ','
      temp += link_to( cat.cname, {:controller=>'categories', :catid=>cat.id.to_s, :action=>'show'})
    end
    return temp
  end



21 May, 2008 | Foodyn | | Andy
« Prev item - Next Item »
---------------------------------------------

Comments


No comments yet. You can be the first!


Leave comment

© 2007 yoursite.com | Designed by DesignsByDarren
Ported to Nucleus CMS: Suvoroff