Giter VIP home page Giter VIP logo

Comments (3)

apotonick avatar apotonick commented on June 14, 2024

Hi Brett,

only including a module doesn't make it available in the view. I hate
helpers and I'm gonna vent my anger in a blog post soon ;-)

Try that:

Class MenuCell < Cell::Rails

...

helper UrlHelper

and lemme know if that helps.

Nick

On Mon, Apr 11, 2011 at 4:32 PM, brett-richardson <
[email protected]>wrote:

Hey, I've been trying to get Cells to render a menu that links to a list of
sub-domains.

I have gone through @wingrunr21's recent pull request for adding the UrlFor
module, but I'm unsure how one should go about getting this working.

My cell looks like this:

   class MenuCell < Cell::Rails

           include ActionController::UrlFor
           include UrlHelper


           def primary
                   render
           end
    end

But I have also tried this method too:

   module UrlHelper

           def with_subdomain( subdomain )
                   subdomain = ( subdomain || '' )
                   subdomain += '.' unless subdomain.empty?
                   [subdomain, request.domain,

request.port_string].join
end

           def url_for( options = nil )
                   if options.kind_of?( Hash ) && options.has_key?(

:subdomain )
options[:host] = with_subdomain(
options.delete( :subdomain ) )
end

                   super
           end

   end


   module Cell
           class Rails < AbstractController::Base
                   include ActionController::UrlFor
                   include UrlHelper
           end
   end

Ideally I think Cells should be able to handle a link_to call like this:

   %li= link_to mod.name, root_url { :subdomain => mod.subdomain }

Do you know what needs to be done here?

Reply to this email directly or view it on GitHub:
#48

from cells.

wingrunr21 avatar wingrunr21 commented on June 14, 2024

brett, including the ApplicationController::UrlFor module in your Cell should be all that is necessary for those types of links to work. I'm using them right now in my site.

root_url(:subdomain => :foobar)

Cell:
class NavigationCell < Cell::Rails
include ActionController::UrlFor

  def nav_links
    ...
  end
end

View:
%li
= link_to(root_url(:subdomain => :courses)) do
%span.pictos W
Courses
%li
= link_to(root_url(:subdomain => :resources)) do
%span.pictos p
Resources
%li
= link_to(root_url(:subdomain => :projects)) do
%span.pictos e
Projects
%li
= link_to(root_url(:subdomain => :alumni)) do
%span.pictos g
Alumni

from cells.

brett-richardson avatar brett-richardson commented on June 14, 2024

Ah, that's great! Thanks. :)

from cells.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.