SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend: Action Helper Vs View Helper

    Hi,

    I'm learning Zend (clearly!)

    And I was wondering what the difference is between an action helper and a view helper. When I go over the material I have ("Easy PHP Websites with the Zend Framework" book) I can't really tell the difference between the two. Functionally they appear to fill the same role... Why would I choose one over the other? What is the purpose of each one?

    Thanks!!
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  2. #2
    SitePoint Member
    Join Date
    Jan 2010
    Location
    India
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    View Helpers can be called from views, and action helper from controller .

    A good article for Action Helper is written by the Lead Mathew . You can read over http://devzone.zend.com/article/3350 .

  3. #3
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks harikt.

    I was fooling around with them and discovered that --- also discovered some differences --- the book was not at all clear.

    I'm not sure of the reason why they are seperated like that and why you might choose one over another (other than that action helpers are much better).

    Is it possible to directly call a method in a view helper class?

    I guess I also just want to know why you'd use one and not the other. My thinking is that in the future if I go back to a project, I'm going to have some things in views and somethings in actions and they're going to be harder to find/work with.


    One example:
    I want to display the credit a customer has and the number of minutes that credit translates into based on their currency. If I use view helpers I can pass their balance and currency from the controller to the view and let it get converted there. But I have to create 1 view to format currency and 1 view to convert the credit to minutes.

    If I use action helpers then I can use 1 helper (with multiple methods) but now I have to pass currency, credits, and minutes to the view.

    Do you get where I'm coming from?
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  4. #4
    SitePoint Member
    Join Date
    Jan 2010
    Location
    India
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you know the differences between view helper and action helper , so I think you can easily deal with it .

    To make it more clear , lets take an example
    You have a form with an action to indexAction() . After the form has been processed , you want to redirect to a success page. Lets think its successAction() . In these cases we are can use action helpers .
    The main aim of view is to remove a huge amount of PHP from the view script . ie why we are running with MVC . Really talking we are dealing with VC ( When application logic is moved to C, ie fatty ) .
    So the V is having less php code , and when we need to make some logic we can use the view helper . Some if() or something . It all depends on our logic .

  5. #5
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks harikt.
    I suppose i'm starting to get it. I guess I just need some time in the Zend trenches -- then I'll start to figure out what needs to go where more specifically (by getting frustrated when I return to projects I suppose!)

    Thanks for some more clarification.
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  6. #6
    SitePoint Member
    Join Date
    Jan 2010
    Location
    India
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •