Blog

Come to MinneBar 11!

The Twin Cities (Minneapolis/St. Paul) technology community is a vibrant place to be. One of my favorite events of the year is coming up in three weeks, the 11th annual MinneBar un-conference. If you are at all a member of the technology community, sign up for a free ticket and join us for a day of learning, sharing ideas and networking. Did I mention there's free food and beer?

The local version on the BarCamp network, MinneBar is one of the largest BarCamp events in the nation. This year, as it has been for the last 6 years, MinneBar is held at the Best Buy Campus in Richfield, MN. Fifty minute sessions are held throughout training classrooms and an auditorium on the campus while the cafeteria is used for free breakfast, lunch and beer after the day's sessions. That's right, stay fed and hydrated while you are learning for free, thanks to the event's sponsors. (Thanks to Best Buy for hosting the space.)

What kinds of sessions will be taking place throughout the day? Well, right now anyone can propose something in the MinneBar Session Picker and others can vote that they will attend the session. The best sessions will get put on the schedule that goes out a few days before the event. As you can see, sessions may be presentations, panel discussions, or even just meetups or discussions among the community members that attend. The topics can vary, from technology topics such as hardware, software, web services, or more to how technology imp\acts the community or even the business side of technology and the local technology and venture capital market. As a PHP web developer, personally, I don't find many of the sessions impact my everyday professional work, but it's great to be curious and learn about other parts of the business and other ideas that local peers are working on. And everyone is there to learn and share knowledge, so feel free to ask questions and discuss ideas as it seems appropriate. Minnebar is also a great chance to see other developers that are local but I do not often see.

How do you attend this event? The tickets are free, but there are some hoops to go through to get them. Sign up for the Minne* E-mail List to be notified of details, but at precisely 7pm on Wednesday, April 6 and 2pm on Thursday, April 12, about 500-600 tickets each will be released on their EventBrite registration page. I recommend you be signed into your EventBrite account and reloading the page to get a ticket, because these tickets usually get snatched up in 5-10 minutes. So set your calendar and you can get a ticket! It's free and just takes a bit of scheduling.

Thanks to the Minne* sponsors and organizers, and I'm looking forward to attending my eighth MinneBar on Saturday, April 23rd!

Why You Should Watch "Person of Interest"

Note: The following article contains mild spoilers about the television show "Person of Interest". The spoilers only reveal much of what is fleshed out in the pilot and the first few episodes as well as the general direction the show goes over it's run so far. If you are averse to spoilers, then suffice it to say that I think you should at least watch the first half of the first season to get a good feel for the show.

Photo of Reese and Finch at a bank of computer screens

I watched the first 10 minutes of "Person of Interest"'s pilot on live TV back in 2011. I turned it off. The show started with a man in bed with his girlfriend. Then he was drinking in the subway. He beat up a few street kids. I figured it was an origin story of an all-to-predictable CBS cop show. But six months later, friends online were raving about the show. It wasn't until September 2012 when it was on DVD that I was able to give it a second look and found that the remaining 33 minutes of the pilot (and the ensuing seasons) proved me wrong. "Person of Interest" is now my favorite show on television.

Yes, the show does start as a twist on the usual cop show format. Mr. Finch (Michael Emerson, "Lost") has built a surveillance machine, and it gives him social security numbers. He investigates the person to find if they are a murderer or a victim. He needs Mr. Reese (Jim Caviezel, The Passion of the Christ and The Thin Red Line), an ex-military, ex-CIA operative to work things out in the field. Their goal is to help people, if they can figure out what is going on in time. A classic TV mystery.

As an aside, one reason I enjoy "Person of Interest" is it's style. Cuts between scenes show the inner workings of the surveillance machine, all the mundane traffic and security cameras that make up it's data. Backstory is given via The Machine's audio and video clips as well. Most scenes are given a very cinematic but realistic look that makes it look great but also gives the feeling that this could be actually happening. The best part, though, is that the show is shot on the streets of New York City, which looks and feels much more grounded in reality than any Hollywood backlot. The location crews find great, real places on and off the streets and it's hard to tell where the real world end and the set dressing begins. And finally, there's plenty of action. Mr. Reese is not trying to kill the bad guys, but he knows how to stop them in their tracks with a well placed punch, bullet, grenade, shoulder cannon or being T-boned by a truck.

Shot of The Machine's data overlaid on a traffic cam

But while you watch the first season's mysteries, you find that something else is going on along with the "person of the week". What is the nature of The Machine that Mr. Finch built? Why did he build it? What is his background? Also, a hard-working cop (Taraji P. Henson, "Empire" and The Curious Case of Benjamin Button) wants to apprehend these do-gooders that are rounding up the bad guys and leaving before she can talk to them. Another cop is working with Mr. Reese to figure out these mysteries even though he doesn't know where the "person of interest" comes from. And they start running into various forces within the city, from corrupt cops to mobsters and even some groups more technologically inclined. So while the show has a weekly format, there is great character development and a storyline that flows through the seasons.

The show also has a science fiction undertone as well. Not that it takes place in a whole different world, but it takes place in a world where the surveillance state is heightened. While today's government organizations likely are able to monitor lots of data, there's no way they can process all of it in real-time. The Machine can process all surveillance data and predict where bad actors may pop up. But also, The Machine starts showing signs of being somewhat of an artificial intelligence. "Person of Interest" explores the consequences of surveillance and an AI having some say in what happens in the future. What does an artificial intelligence think of the humans that created it? What would happen if it ran the world? These ideas are being explored more and more in the 3rd and 4th season. Becaiuse of this, less and less episodes are the mystery of the week but instead are a more serialized storyline.

Photo of Mr. Finch looking up at a surveillance camera

"Person of Interest" has been my favorite show on all of TV since I started watching in 2012. It was not the mystery of the week that really drew me to the show, although that draws some, but it was the bigger story that built over the first season that got me hooked and made it my favorite show on television. These themes continued to expand throughout the next three seasons. I thought the latter half of the fourth season was a little weak, but I hope for a return to form in the fifth and potentially final season. But hey, if you watch the four seasons this fall and then watch on TV or CBS.com this winter, hopefully "Person of Interest" will continue to create great characters, riveting action and speculate on the effects of tomorrow's technology for a few more years. I sure hope it does.

"Person of Interest" seasons 1-3 are now available on Netflix streaming in the US. I also have them on Blu-Ray and DVD if you want to borrow them. I have season 4 on Blu-Ray as well, as well as season 4 comes to Netflix on September 22. Also, starting September 3rd, check out my favorite new network TV show of the 2014-2015 season on Netflix—it's called "Madam Secretary".

Categories: 

Introduction to Web Accessibility Slides

In an hour or so I will be giving this presentation at Twin Cities DrupalCamp 2015. I am no expert at Web Accessibility, at least not yet, but I wanted to share what I have learned.

2 + 2 = 5 Shirt

The return of the T-shirt posts! This is a shirt I've had for a year or two and, like some of the other geeky, math-related shirts I have, they get lots of response. Sadly, most comment that the shirt is wrong because they do not understand the match concept, but a small minority of knowledgeable folks know the details and quietly and calmly say they like the shirt. Here's a bad photo of it:

2 + 2 = 5 Shirt

The shirt says "2 + 2 = 5" in big yellow chalkboard-style lettering with smaller text of "For extremely large values of 2" beneath in smaller letters on the front The black shirt has nothing on the back. The shirt was given to me as a Christmas gift from my sister and brother-in-law, if I remember correctly. (Good math fans to pick that one out.) The shirt was then available from ThinkGeek.

What this means to me is that math is somewhat relative. Usually, "2" is assumed to be an integer, but in math, "2" could be representative for any number, such as "2.3" or "6.0". And, more importantly, as a programmer, after a bit of programming with numbers you learn that math is hard. In many languages, how the data is stored and represented during processing can make the math not work as expected. For example, if you add integer "2" to decimal "2.6", the language may just automatically convert the decimal to an integer by lopping off the decimal part, so the answer may be the integer 4. To get an accurate result, you may have to force the integer to become a decimal "2.0" and then you'll get a decimal result, "4.6", from an add operation. So, to me, it shows that math is not as simple or straightforward as you think it may be.

Incidentally, all employees behind the counter at the Highland St. Paul Chipotle this afternoon were adamant that this shirt was completely wrong and one was even disturbed that someone would not agree it is wrong. I, as usual, just smiled and said it's a confusing math joke.

Categories: 

Building SEO-Friendly Sites with Drupal Slides

Today I gave a session at Twin Cities DrupalCamp 2014 called Building SEO-Friendly Sites with Drupal. Attached here is a PDF of the project slides. Thanks to all who came out to the session.

Tags: 

"Grace Is An Ocean" T-Shirt

The T-shirt blog posts are back! This photo is definitely not very flattering, mostly because the shirt text is down the side of the shirt. But the content makes up for it. It's a maroon shirt with text written down the right side in a serif font.

Photo of a maroon shirt with 'If Grace Is An Ocean We're All Sinking' printed on it.

This is one of my newest shirts. The words "If Grace is an Ocean We're All Sinking" is a line from a song titled "How He Loves". Although the song was made popular by the now defunct David Crowder Band, the song was originally written and performed by John Mark McMillan. McMillan is a man that loves to make rock music that is still somewhat worshipful. Here's the song's full lyrics:

He is jealous for me
Loves like a hurricane
I am a tree
Bending beneath
The weight of his wind and mercy
When all of a sudden
I am unaware of these
Afflictions eclipsed by glory
And I realize how beautiful you are
And how great your affections are for me

Oh how he loves us so
Oh how he loves us
How he loves us so

Yeah he loves us
Oh how he loves us
Oh how he loves us
Oh how he loves

We are his portion
And he is our prize
Drawn to redemption by the grace in his eyes
If grace is an ocean we’re all sinking
So heaven meets earth like a sloppy wet kiss
And my heart burns violently inside of my chest
I don’t have time to maintain these regrets
When I think about the way

That he loves us
Oh how he loves us
Oh how he loves us
Oh how he loves

You can hear one of John Mark McMillan's recordings of the song at his website. It's good stuff. Very raw and rock 'n' roll but also worshipful.

I got the shirt as a bonus for donating money to his campaign to create a new album. It was successful, and I have to say that "Borderland", the resulting album, is his best yet. Plus it's got cool, gutsy artwork. If you like the sound, you should certainly grab a copy.

Borderland CD Cover

Categories: 

The iPad & the Birth of Digital Publishing

First, a personal note about the iPad. For me, as I explained in my post about why I don't want an iPad, the new, thinner, lighter iPad mini is probably the only iPad I am interested in buying. This is because it is lighter, thinner, and, as Apple is quick to point out, easier to hold in one hand and easier to hold up without getting your arm tired. However, as a person who is in front of my computer at any time when at home and is happy with my iPhone as a traveling companion, I still cannot find a reason I need to buy an iPad. Between my iPhone and my MacBook Pro, there's nothing I really want to do that makes me think, "I need an iPad." The only reason I might want an iPad is for digital magazines, and that is my main topic for today.

The publishing industry is scared. They know that someday, no one will buy their newspapers and paper-based magazines. The world of paper books will probably live on longer in a niche market, much like music on vinyl still exists. In fact, many are not buying these paper magazine/newspaper versions anymore and instead just visiting the publication's website for their content. But I don't think the end of paper is coming nearly as quickly as these companies are thinking. No, this prediction has nothing to do with the apocalypse like the TV show "Revolution" or the movie "The Book of Eli". But I firmly believe there are some conveniences of paper publications that are still not solved digitally. Until these hurdles are overcome, paper will still be more universal and preferred.

The biggest problems is that publishers need to make reading ubiquitous. Amazon.com has done the best of this so far. I can read my Kindle books on my computer, on my iPhone, and on my Kindle itself. There's maybe a limit of devices i can load some content on, but I've never run into it. It just works, and it works everywhere. But magazine/newspaper publishers have a long way to go in this area. One of my favorite magazines was Paste Magazine, which had to stop printing a year or two ago. Shortly after that, they announced a weekly e-magazine available on their website for a couple bucks a month, and I've purchased it. But honestly, I haven't really read it much I'm just not sitting at my computer at home thinking, "I want to read about music and movies right now." I mostly read Paste in print while on long car trips or airplane flights, among other places, and I really cannot do that with the Paste mPlayer product right now. Heck, their product (last I checked) doesn't really work on my iPhone for reading either. However, they have announced they plan to have an iPhone and iPad app sometime in the future, which promises more great reading time.

Another favorite small magazine publisher of mine is Relevant Magazine. They are still committed to printing a magazine, which I love. I still subscribe and do read them. But now they also allow me to read them on their website if I log into my account, and I appreciate that. Their new website is very well-designed as well--it's amazing how it feels like a magazine, almost, with colorful graphics, enlarged blurbs from the article, and multimedia in the margins. It's one of the best publishing websites I've seen so far (much like The Verge, which I will accuse them of plagiarizing a bit). Relevant does offer a beautiful iPad app, I'm told, but since I don't have an iPad, I may never experience it. Still, though, I should be able to read Relevant everywhere. I'd read it more if they had an iPhone app in addition to the iPhone app. I'd read the articles on my Kindle if it didn't cost more and was an available option. Yes, I know, in these formats I would not get as much of the fancy graphics, the meticulous layouts, and the experience of reading a glossy, full-color magazine printing, but is that so terrible? In the end, I want to read the content, and for the most part, it is about the content, not the presentation. Don't get me wrong: the presentation is great, where available. But I would rather be able to read the words anywhere and be aware that I am missing a bit of the experience instead of not reading at all.

Another problem with digital distribution is the reader's lack of rights. If I get a paper version, I can meticulously save them on my shelf for reading whenever I want. I can easily borrow them to a friend. I can even give them to my kids, if they do not fall apart by then. I own these books. These days, when you purchase digital books, you do not own them. You are given a license to read them that can easily revoked by the seller or the publisher. You get much less rights than with a paper book or magazine. A couple weeks ago, a woman's account from Amazon was deleted and she was not told why. Most likely, she violated some parts of the terms of service, but still, she may have spent hundreds of dollars on electronic goods that she no longer had access to and very little recourse to getting her books back. The printed word does not come with a 20-page legal agreement attached--it just comes with a copyright and that's about it.

Digital distributors like Amazon have done a lot to mitigate these problems. I can read my books on numerous devices, and Amazon keeps track of where I am at on one device and lets me pick up from that spot on another device. They even have a mechanism for me to lend a book to a friend's Kindle account for a preset amount of time. You can also borrow books from the worldwide Kindle pool at your local library for a specified amount of time. But, again, all of these are subject to the agreements of Amazon.com and the publishers, so you may find some of this not working from time to time. That said, I love my Kindle. There's no other easy way to carry around dozens of books in one small, lightweight package that can easily be tossed into my backpack.

Within the last month the publication Newsweek announced they would stop printing a magazine at the end of this year. Many smaller publishers have started distributing digitally first and then printing a book copy months later for the die-hard fans. I think these are signs of the times, and digital distribution is so much cheaper. But at this point, paper is still just as convenient and comes with more rights. Will Newsweek lose readers when they stop printing? For sure. Will they have a viable business in the e-publishing world? Only time will tell. But I think that digital publishers need to make their content much more available everywhere digital goods are sold in order to gain the widest audience, not just on the iPad or Kindle store. In the end, the product available everywhere will make the most money. It is a problem of building the infrastructure and standards to enable that availability.

Getting Around and Staying Fit with Nice Ride

Somewhat-reputable sources list the Minneapolis/St. Paul area as one of the "most liveable" cities in the country. I'm not sure if I believe that; I've seen many places that seem just as nice, although this is the only city I've lived in. Other places have listed the metro as a very "bike-able" area, and I'm starting to believe that. I know I've had some minor hostility from drivers on the road and some genuine hatred towards bikers from my friends who drive, so we probably still have a bit to go as well. However, a new development in the last year or two has shown that cycling is at least growing and somewhat popular and maybe even a sustainable business can be mad with it. This morning I got a chance to try Nice Ride for myself, and it seems like a valuable service to urban members of the Twin Cities.

Nice Ride Rider and Station (from cedwardmoran's Flickr)

Nice Ride is an organization heavily funded by local companies, including flagship sponsor, Blue Cross Blue Shield of Minnesota, who spends a lot of money on marketing to encourage Minnesotans to stay active, and whose logo appears on each Nice Ride bike. Nice Ride currently operates 145 stations in and around both downtown Minneapolis and downtown St. Paul, including the six miles or so between downtowns. From any one of those stations, you can rent a bicycle and return it to that station or any other station when you are done.

For a one-time newcomer such as myself, a payment of $6 to my credit card will get me unlimited rides for the next 24 hours. Longer-term users of 30 days or the whole April-November bicycling season pay $30 or $65, respectively, which is much more reasonable. Additional trip fees are incurred if the bike is away from a station for more than 30 minutes, so the program is definitely geared towards folks who just need to take a short ride around town, not for long-term cyclers. Monthly or yearly subscribers also receive a small, plastic key with an RFID tag for their account which gives them immediate access to a bike from any station; less frequent users have to put a credit card into a card machine at one end of the station to gain access to a bike. Many other cities across the country and the world have similar programs, so you can get locations of stations and availability of bikes data from the SpotCycle app for your smartphone.

The bicycles themselves are simple but functional. The bike is rather heavy and well-built. It comes with only three gears, so don't expect going very fast. But you can get the bike going fast enough; there's just not that acceleration that you would get from a fancier bike. The bike does not have large treads on the wheels and is thus designed for the many trails of Minneapolis/St. Paul and the city streets. The bike does come with a rack on the handlebars with the potential to carry a bag, although it seems to me you would need to have a bit more tools with you to secure something on there. Overall, it's a functional bike, but nothing you'd want o own personally. After my ride, I did read on the Nice Ride FAQ page that I'm actually a bit over their maximum weight limit, but I'm not sure that this will stop me from using the service again.

This morning, I was able to take a city bus to a nearby Nice Ride station. From there, I biked 3-4 miles into downtown to run some errands. Since my bike is currently broken, it was nice to be able to just pick up a bike, go on a ride, and then just leave it at my destination and take the bus home. There are stations nearby many bus and train stops, and especially for downtown, there is a Nice Ride station within a block or two of any location. Since I am personally uncomfortable biking after dark due to my poor eyesight, I can see myself biking to a concert or other evening event and then being able to take the bus or light rail home that night. You don't have to worry about locking up a bicycle and it getting stolen, you just deposit the bike at a nearby station.

Yes, it's a helpful service, but will I be getting a yearly subscription? Not right now. I currently live in the Highland area, a couple miles from the nearest station. If there was a station only a short walk from my apartment, I would be very likely to purchase a subscription and use it for a bit of fresh air while heading around town. It definitely makes sense to start up a service like this in the downtowns and more populated neighboring areas, but I hope it continues to expand throughout the cities of Minneapolis and St. Paul.

Another question about this service is: Can it be profitable? Yes, it is organized as a non-profit right now and is heavily supported by local corporations, but is it profitable? Could it be profitable? A non-profit can be one way to kickstart a business, but but is this always something that will be around as usage grows and the donors dwindle? It seems that most other U.S. metros that have similar programs have them set up in a similar way, so only time may tell, I suppose.

Categories: 

The Olympics Broadcast: Is It An #NBCfail?

It's been over two years since the last Olympic Games, and four years since the last Summer Olympics. Broadcasting the Summer Olympics exclusively since 1988 and the Winter Olympics since 2002, U.S. broadcaster NBC has cemented itself as the Olympics network. (Incidentally, NBC has already secured broadcast rights of every upcoming Olympics through 2020.) During the games, for years, they have pre-empted nearly all of their network programming to bring at least 12 hours per day of coverage over broadcast. With the advent of cable TV over the last 20 years, much more coverage has been added on various affiliated cable channels. At this point, NBC really has this Olympics broadcasting thing down to a science. And their broadcasts are great. For the past week, I've watched about 6 hours of coverage per day, maybe even a bit more. If watching NBC is your only exposure to the Olympics coverage, then you have nearly no reason to be dissatisfied. But, then again, with the latest advances of the Internet, we have been taught to demand more.

Without my Elgato EyeTV USB TV Tuner and DVR software, I would probably not be watching any of the Olympics. Through the TV Guide built into the software, I can record all the Olympics I want. I can skip through the commercials. I can press pause whenever I want to make dinner or change the laundry, then come back and resume it later. Most of the world may not have this functionality incorporated with their broadcast TV tuner, but they are increasingly used to being able to find it later on YouTube, Hulu, or other services. In this area, NBC Sports is definitely a bit behind the curve. Yes, their website is full of highlights videos, so I could see the last 30 seconds of last Sunday's Women's Cycling Road Race, but I could not watch the last 10 minutes of the race on demand, which is the part I missed while I was at church. If they were to server the audience as best as possible, viewers could watch any event after it happened. The so-called "experts" at these major media companies say they cannot put the same amount of advertisements into the content, but I disagree. I just want to watch it when I want, and it shouldn't matter to Chevy, Proctor & Gamble, and Visa if I watch it in primetime tonight or during my workout tomorrow morning; I'm still a valuable customer.

One solution I've not yet mentioned is on the NBC Olympics website. They advertise being able to watch every event live and offer the ability to replay many events that are not going to be aired later on TV. However, what they don't mention is that you have to be a subscriber of one of their partner cable providers. That is, if I was buying cable service, I could watch every event live. How does this make any sense? I just checked, and for $20 more per month than I currently pay for Comcast internet service, we could get this feature, but at that price, we still wouldn't get any of the NBC affiliate channels who are broadcasting many events such as Tennis and Basketball live. So, most likely, to get most things via cable, you'd be paying $30/month for cable TV service. Most likely, NBC Universal, which is now at least partially owned by Comcast, gets somewhere between $2 and $5 of that $30 I'd be paying monthly. Apparently, I'm in the 50% of American TV-viewing households who do not pay $12-$60 per year to NBC, therefore I don't deserve access to their content whenever I want. Also, apparently I am not worth being the target of much marketing, because none of that extra money you are paying means that you get to see less advertisements; you pay the privilege to see more content with just as much advertising in it. As far as I can figure, if NBC really wanted to make money off of advertising, they would want me to watch as much content, with ads intelligently inserted. But no, I have to pay to be advertised to maximally. That makes no sense to me.

Also, today's Internet culture makes everything a real-time affair. Enough people around the world are watching live, and if you are on Twitter or Facebook at all, you will find the results before NBC gets around to broadcasting it. This was not a problem two years ago with the Vancouver winter games, where the time is the same as the U.S. West Coast, and therefore nearly everything can be broadcast live. But with a six-hour time difference, most of the night's major events are happening just after lunch on this side of the pond. Again, this works pretty well if all you are watching is NBC's broadcast, but not if you are looking at any other news sources. (Although, NBC has had a problem or two of spoiling it for fans accidentally as well.) This afternoon, when Michael Phelps was competing in the 4x200M Swimming Final, possibly his last competition at the Olympics ever, it was not broadcast live. At least one viewer (who apparently has paid for cable) was complaining on Twitter that the stream was failing. It wasn't that his local internet access was not working, most likely, it was that NBC/YouTube's live streaming servers couldn't handle the hundreds of thousands of Americans who wanted to watch the race live. This, actually, is currently an Internet architecture problem that can be fixed if companies like Comcast put up a bit of money to get IPv6 multicast working across their networks. Streaming live events to millions over the Internet is very hard today, from what I know about networking as it currently stands, and maybe that is why NBC does not want me to watch online. That, or maybe NBC is in bed with the cable companies to make sure they get their $3 from me to sell me more advertising.

Yes, that's a lot of minor problems that NBC has in today's fast-paced Internet world. In future Olympics, they are only going to get worse unless they keep working on this. But until then, I will watch 5 more hours of Olympics coverage tonight and keep watching more tomorrow. I guess I won't be watching in future years, though, NBC, unless you make it easier to catch the action between other live events of my live, which may be busier in the future.

A Basic Drupal Module

My co-worker, Joe Tower, is a designer/developer who is just getting into coding his own Drupal modules. Over at his blog, earlier this weekend, he created a basic module. I thought it needed a couple more things, so I'm gonna pick up where he left off. You might learn a bit or two about how the innards of Drupal work if you keep reading.

First of all, I took his basic my_menu_module_form_content_type_form_alter() function and made it a bit more general. This version of the function, using the less specific hook_form_alter() function, is defined as my_menu_module_form_alter(). This code below searches for any content add/edit form and sets the checkbox to default to checked:

function my_menu_module_form_alter(&$form, &$form_state, $form_id) {
  if (substr($form_id, -10) == '_node_form') {
    $form['menu']['enabled']['#default_value'] = TRUE;
  }
]

I'm pretty sure that's not exactly what we want to do, though. This is where Drupal's built-in variable system is very helpful. Using the functions variable_set() and variable_get(), you can set/get small bits of data very easily. In this case, we're just setting "1" or "0", which is synonymous in this case to TRUE or FALSE. Therefore, this is the version of the above function where we get the content type name from the form id and then check a variable that is specific to that content type.

function my_menu_module_form_alter(&$form, &$form_state, $form_id) {
  if (substr($form_id, -10) == '_node_form') {
    $content_type = substr($form_id, 0, -10);
    $form['menu']['enabled']['#default_value'] = variable_get('my_menu_module_' . $content_type . '_enabled', FALSE);
  }
}

Now, we need to create a checkbox on the Content Type edit page. To do that, we'll use another form_alter function:

function my_menu_module_form_node_type_form_alter(&$form, &$form_state, $form_id) {
  $form['menu']['my_menu_module_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Default the "Provide a menu link" item to checked.'),
    '#default_value' => variable_get('my_menu_module_' . $form['#node_type']->type . '_enabled', FALSE),
  );
  $form['#submit'][] = 'my_menu_module_type_form_submit';
}
 
function my_menu_module_type_form_submit($form, &$form_state) {
  variable_set('my_menu_module_' . $form_state['values']['type'] . '_enabled', $form_state['values']['my_menu_module_enabled']);
  return;
}

Also, as you can see, I added a submit function that saves our custom variable. You'll also notice that the variable_get() function always expects a second variable which is the default value if this variable is not set. So, now you should have a much more functional module that has a checkbox on each content type's admin interface to decide if this will be defaulting to true on your site's content types.

Update: My co-workers have created a Drupal module out of this idea. Check out the Default Menu Link module. It might just help you out.

Categories: 

Pages