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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:14:12+00:00 2026-05-22T15:14:12+00:00

Lets refer to ‘ Sort by ‘ section on Yelp: I have 3 anchor()

  • 0

Lets refer to ‘Sort by‘ section on Yelp:

I have 3 anchor() functions that generate the 3 links. When one of the ‘sort by’ option is selected, I want to remove the hyperlink/anchor() and bold it to show that it is selected just like on the page above.

Right now I am thinking of doing a uri_to_assoc() to $arr because the selected option will be in the url like controller/function/sort_by/best_reviews/.., then based on what is the key (best_reviews) or element (sort_by), use the following code in view

<?php
$arr = uri_to_assoc(3);

if($arr['sort_by'] == 'best_reviews') {
    echo "<strong>Best Reviews</strong>";
} else {
    anchor('controller/function/sort_by/best_reviews', 'Best Reviews');
]
?>

Now I believe the MVC idea is to keep little php code (logic code?) in the view. In this case, will you put the above code in the view, or have that logic in controller/model then pass the final code to display (either the echo or the anchor()) in an array and just echo the array in view?
.

.

Mini Question (PHP)

If $arr[‘sort_by’] is not defined in the case that /sort_by/variable does not exist in the url, the statement if($arr[‘sort_by’] == ‘best_reviews’) will give an error. Will u nest all the above code in a if(isset($arr[‘sort_by’])){} ?

  • 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-22T15:14:13+00:00Added an answer on May 22, 2026 at 3:14 pm

    You are modifying presentation, so you must do it in the view. It has nothing to do with any business logic whatsoever. You can use code in the view, but for the sole purpose of presentation; there’s no limit on the amount of code, only on the purpose of it.

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

Sidebar

Related Questions

Lets say that you have websites www.xyz.com and www.abc.com. Lets say that a user
well, i have network that each proxy (lets assume we have 200 proxies), send
Let's say I have a fixed sidebar that is XXpx tall (Refer to http://www.getskeleton.com/
coming from clojure I need to write some javascript functions Lets say I have
Lets say I have a custom data type that looks something like this: public
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have several web sites on my web server, all as applications
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
Lets say I have the following JavaScript: var obj = { key1 : "it

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.