Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:38:52+00:00 2026-06-09T20:38:52+00:00

I currently have a writers MVC that is working. I have a firstname and

  • 0

I currently have a writers MVC that is working. I have a firstname and lastname property. On the index I want to display the full name. I understand that this can be done several ways.

I can write the logic in the view

echo $writer['Writer']['firstname'] . " " . $writer['Writer']['lastname'];

I can write a helper function to do this and keep my view clean. This is how I currently do it.

echo fullName($writer['Writer']['firstname'], $writer['Writer']['lastname']);

I was wondering however if it would be a better to create a writer class that has a fullname method. Then I could simplify my view a bit more.

echo $writer->fullname

So, I know how to write helpers and this works, assuming that building a class is the way to go, when is the right time, after a query to instantiate each object? I assume in the controller. Further, where would my class reside?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:38:54+00:00Added an answer on June 9, 2026 at 8:38 pm

    create a helper CustomHelper (anything you like) in your View/Helper/.
    Then a method fullName:

     public function fullName($writer) {
        return $writer['first_name'] . ' ' . $writer['last_name'];
     }
    
    // in your view
    echo h($this->Custom->fullName($writer['Writer']));
    

    You can also make a behavior to format in on find() already.
    It depends where you are going to use it. If it is only view related, helpers would suffice. If you need it at controller/model level you might want to use the model layer to concatenate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently have a drop down menu that is activated on a hover (from display:none
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have one project that currently contains multiple packages. These packages make up
I currently have a form with inputs and name attributes. I'm able to get
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I currently have an iPhone app that reads data from an external XML file
Edit: solution added. Hi, I currently have some working albeit slow code. It merges
currently I have a disfigured avi file that a program of mine creates. I
I currently have a multi-threaded program that crawls websites and writes their text to
I currently have this code that parses imdbAPI http returns: text = 'unicode: {Title:The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.