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 7654089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:11:31+00:00 2026-05-31T12:11:31+00:00

I wanted opinion is it a good practice to do things like this while

  • 0

I wanted opinion is it a good practice to do things like this while working with MVC architecture:

{foreach from=$items item="list"}
  {if $list.index < 5}
    {assign value="good" var=$class_name}
  {else}
    {if $list.index % 2 eq 1}
      {assign value="bad" var=$class_name}
    {else}
      {assign value="average" var=$class_name}
    {/if}
  {/if}
{/foreach}

Or should I do such things inside php and then just access with:

{foreach from=$items item="list"}
  {$list.class_name}
{/foreach}

The reason I’m asking this is, because I was told it’s need to be done inside templates(because it’s styling issues and etc), but I think opposite, I think it needs to be done inside PHP controller so that way you leave templates a little bit cleaner.

So what is the better approach and why?

  • 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-05-31T12:11:33+00:00Added an answer on May 31, 2026 at 12:11 pm

    If you referring class_name as in the <a **class="class_name"**>, then yes, You should generate that in the smarty template so that the template has control over how it should look. If you referring class_name to something else that is class Class_name, and you want to print that out. Then no, it should stay within your PHP code.

    But all these are neither best practices stated anywhere or documented, but more company standard or team lead preferences. And you do what they want if you want to keep your job smooth and easy.

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

Sidebar

Related Questions

I just wanted opinion on good workflow using the emacs environment with clojure+swank+slime. I
I wanted to get your opinion about managing scripts in ASP .NET MVC. There
I wrote this, and wanted to get everyones opinion. I use this when I'm
I wanted to know what the public opinion is about Resharper vs Devxpress CodeRush
I just wanted to hear the opinion of Hibernate experts about DB schema generation
I just wanted some opinions from people that have run Selenium ( http://selenium.openqa.org )
Ok, so I wanted to get opinions on this topic. I have a dumb
Wanted to get some consensus around a UI feature I'm working on right now.
I'm currently working on an ASP.NET 3.5 project, and I wanted to know your
I am going back and forth with my team on this and wanted to

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.