Search Results

Search found 32 results on 2 pages for 'sprugman'.

Page 2/2 | < Previous Page | 1 2 

  • What do you name your files when using MVC?

    - by sprugman
    When using the MVC pattern, which I'm not terribly experienced with, I find myself naming things like this: /app/views/widget.php /app/models/widget.php /app/controllers/widget.php That appeals to me because it's easy to find associated classes, and I lean towards shorter names when practical. However, when I'm looking in my IDE, I see three different files called widget.php, which is confusing. I'm tempted to add "_v", "_c", "_m" or something to each name. How do you handle this? FWIW, I'm using CodeIgniter at the moment, and I don't know if there are any special benefits to using a particular convention, or any standard practices. Regardless, I'm intersted in the best-practices from various platforms.

    Read the article

  • how to get all the menu items below a certain parent in drupal?

    - by sprugman
    I really only need the mlid and title text for the first level below a certain menu item. Here's what I'm doing at the moment. (It works, but I suspect there may be a more drupal-y way.): /** * Get all the children menu items below 'Style Guide' and put them in this format: * $menu_items[mlid] = 'menu-title' * @return array */ function mymod_get_menu_items() { $tree = menu_tree_all_data('primary-links'); $branches = $tree['49952 Parent Item 579']['below']; // had to dig for that ugly key $menu_items = array(); foreach ($branches as $menu_item) { $menu_items[$menu_item['link']['mlid']] = $menu_item['link']['title']; } return $menu_items; } Is there?

    Read the article

  • database design help for game / user levels / progress

    - by sprugman
    Sorry this got long and all prose-y. I'm creating my first truly gamified web app and could use some help thinking about how to structure the data. The Set-up Users need to accomplish tasks in each of several categories before they can move up a level. I've got my Users, Tasks, and Categories tables, and a UserTasks table which joins the three. ("User 3 has added Task 42 in Category 8. Now they've completed it.") That's all fine and working wonderfully. The Challenge I'm not sure of the best way to track the progress in the individual categories toward each level. The "business" rules are: You have to achieve a certain number of points in each category to move up. If you get the number of points needed in Cat 8, but still have other work to do to complete the level, any new Cat 8 points count toward your overall score, but don't "roll over" into the next level. The number of Categories is small (five currently) and unlikely to change often, but by no means absolutely fixed. The number of points needed to level-up will vary per level, probably by a formula, or perhaps a lookup table. So the challenge is to track each user's progress toward the next level in each category. I've thought of a few potential approaches: Possible Solutions Add a column to the users table for each category and reset them all to zero each time a user levels-up. Have a separate UserProgress table with a row for each category for each user and the number of points they have. (Basically a Many-to-Many version of #1.) Add a userLevel column to the UserTasks table and use that to derive their progress with some kind of SUM statement. Their current level will be a simple int in the User table. Pros & Cons (1) seems like by far the most straightforward, but it's also the least flexible. Perhaps I could use a naming convention based on the category ids to help overcome some of that. (With code like "select cats; for each cat, get the value from Users.progress_{cat.id}.") It's also the one where I lose the most data -- I won't know which points counted toward leveling up. I don't have a need in mind for that, so maybe I don't care about that. (2) seems complicated: every time I add or subtract a user or a category, I have to maintain the other table. I foresee synchronization challenges. (3) Is somewhere in between -- cleaner than #2, but less intuitive than #1. In order to find out where a user is, I'd have mildly complex SQL like: SELECT categoryId, SUM(points) from UserTasks WHERE userId={user.id} & countsTowardLevel={user.level} groupBy categoryId Hmm... that doesn't seem so bad. I think I'm talking myself into #3 here, but would love any input, advice or other ideas.

    Read the article

  • How do you like to define your module-wide variables in drupal 6?

    - by sprugman
    I'm in my module file. I want to define some complex variables for use throughout the module. For simple things, I'm doing this: function mymodule_init() { define('SOME_CONSTANT', 'foo bar'); } But that won't work for more complex structures. Here are some ideas that I've thought of: global: function mymodule_init() { $GLOBALS['mymodule_var'] = array('foo' => 'bar'); } variable_set: function mymodule_init() { variable_set('mymodule_var', array('foo' => 'bar')); } property of a module class: class MyModule { static $var = array('foo' => 'bar'); } Variable_set/_get seems like the most "drupal" way, but I'm drawn toward the class setup. Are there any drawbacks to that? Any other approaches out there?

    Read the article

  • access a property via string with array in php?

    - by sprugman
    (This is in drupal, but I don't really think that matters.) I have a big list of properties that I need to map between two objects, and in one, the value that I need to map is buried inside an array. I'm hoping to avoid hard-coding the property names in the code. If I have a class like this: class Product { public $colors, $sizes; } I can access the properties like this: $props = array('colors', 'sizes'); foreach ($props as $p) { $this->$p = $other_object->$p; } As far as I can tell, if each of the properties on the left are an array, I can't do this: foreach ($props as $p) { $this->$p[0]['value'] = $other_object->$p; } Is that correct, or am I missing some clever way around this?

    Read the article

< Previous Page | 1 2