Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthoradityamooley
     

    In my blog post application I want to display all the keywords on the right column for every page. For this I will have to fetch the keywords from database and then display it in my default application view.

    I want to know what is the best way to do this in Akelos.

    Do we have elements and components available? I see that the constants for these are defined in constants.php but could not find any reference to them.

    •  
      CommentAuthorbermi
     

    You can use partial for reusing view blocks, if I understood what you meant.

    •  
      CommentAuthoradityamooley
     

    Partial is ok. But where will I write the code to get the keywords from databse? Should that go to beforeFilters ?

    •  
      CommentAuthorbermi
     

    Fetching can be done from before filters. I also recommend you to cache rendered keywords if they don't change frequently.

    •  
      CommentAuthoradityamooley
     

    Thanks for the clarification.

    Are you planning to add components and elements in near future. This is the ideal case for using these.

    •  
      CommentAuthorbermi
     

    Seems that you're suggesting features you found on CakePHP and Rails, here you have what I think of those two. Please correct/convince me if I'm wrong.

    Components are deprecated in Rails and it might not be implemented in Akelos. It adds a layer of complexity to a problem that can be effectively solved using partials and helpers. The overhead of using components (filters, extra template and controller instances) is not worth its value.

    Regarding elements, it sounds like partials but with catching abilities. I would like to see the ability to cache partials on Akelos, but not sure about creating another new concept for that.

    Please have your say on this subject.

    •  
      CommentAuthoradityamooley
     

    Are you suggesting to connect to database in helpers?

    AFAIK, helpers are there for views and they should strictly follow that convention. And components are like helpers for controllers.

    Also, IMHO there is no point in cluttering the beforeFilter with this kind of logic which has actually nothing to do with any action.

    As far as the overhead is concerned, the component part will come into play only when they are used. And there is no need of extra template, I think partials can be used very well with components eliminating the need for elements.

    Finally Rails deprecating the components shouldn't be the deciding factor in implementing it in Akelos. There are features in Akelos which Rails has implemented differently like Scaffolding.

    •  
      CommentAuthorbermi
     

    I appreciate you comments and will play with components in Rails during the next week to see the benefits they provide.

    AFAIK, helpers are there for views and they should strictly follow that convention.
    

    The ActiveRecord helper interacts with the database. Accessing Models data is OK in the views/helpers. What is discouraged is altering models from those places.

    And components are like helpers for controllers.
    

    So why call it helper/components and not just helper?

    Does this mean that altering Models is OK from within components? IMHO components should not be used for manipulating Models in a different way than a helper. What about if a components expects some parameters that where not intended for itself?

    Also, IMHO there is no point in cluttering the beforeFilter with this kind of logic which has actually nothing to do with any action.
    

    If so, I can't really see the difference between a helper. You can also call a helper from within your controller in Akelos. Just

    $this->keywords = $application_helper->get_keywords();
    

    it's a good practice not to output directly from your methods, so you can still assigning the return value of a helper to a variable in your controller or use the simpler:

    <%= get_keywords %>
    

    in your view.

    Finally Rails deprecating the components shouldn't be the deciding factor in implementing it in Akelos. There are features in Akelos which Rails has implemented differently like Scaffolding.
    

    I agree, but generally the Rails community trends to removing duplicated functionalities in favor of simplicity .