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

  • Home
  • SEARCH
  • 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 8068393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:40:15+00:00 2026-06-05T12:40:15+00:00

Not sure if it’s a best practice, but we wish to have a menu

  • 0

Not sure if it’s a best practice, but we wish to have a menu on a layout view and pass as URL parameter a value that should retrieve some data.

The menu would be something like:

<ul id="menu">
<li>districtA</li>
<li>districtB</li>
<li>districtC</li>
</ul>

So something like:

'url'=>array('/event/getEventsByDistrict', 'district'=>id),

Is there a better way to do it?

I mean, by doing like this, I believe, if a new district gets added to the database, then we should edit the menu by hand, placing the corresponding id there ? Isn’t there a way to retrieve that id from the database, so that, every time the menu is rendered, we may be sure that that new item will link to the appropriate id of that new (just added district?) ?

Does this makes sense to you?

It seems that the only way could be that of creating a wrapper class or something ?

Perhaps districts are NOT a good example, they don’t change often, but let’s imagine something that changes often.

Please advice

  • 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-05T12:40:17+00:00Added an answer on June 5, 2026 at 12:40 pm

    If I understand your question correctly, this should work, assuming your District model has a name property.

    $districts = DistrictModel::model()->findAll();
    $menu = array();
    foreach($districts as $district) $menu[] = array('label'=>$district->name, 'url'=>array('event/getEventsByDistrict', 'district'=>$district->id));
    
    $this->widget('zii.widgets.CMenu', array(
        'items'=>$menu
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure how to ask this, but i'll give it a try: I have
not sure what i'm missing, but here ti go's: i have a floating left
Not sure what parallel programing means... but I have two thoughts of that Process
Not sure if this is possible but I have a slideshow on my site
Not sure I have the best title for this question. Feel free to modify
Not sure if this is possible in Python, but I'd like to have an
Not sure if I worded this correctly ... but I have the following code:
Not sure if I can word this right but here we go. I have
Not sure if there's a better way to do this but I have a
Not sure if I have a simple typo somewhere, but I'm running into issues

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.