Let’s say you have a view in which you take in an argument you use for filtering content. That’s very easy, but what if you also want to display, say, “Most Recent {ARGUMENT}” before the list of content? It’s not as easy as it seems like it should be. It would be nice if there were a token-based solution, but the best way I can find is to use PHP in the view header.
You’ll need to enable the PHP Filter module, which is a core module that comes with Drupal.
I got this method from this comment, but I thought I’d repeat it here so that it will be easier to find for someone in the future. This takes the argument, turns the ‘-’s into spaces, and capitalizes every word. You may only want to do some of that, or something else, but it demonstrates how to get the argument to do with what you wish.
$view->args
is an array of the arguments in the request.
Here’s the code:
<h2>Recent
<strong>
<?php
$view = views_get_current_view();
print ucwords(str_replace('-', ' ',$view->args[0]));
?>
</strong>
</h2>
Do you know of a better way? Maybe one without having to use raw PHP in your view? That’s what the comments are for! (and thanks)
The Principle of Least Surprise is a common axiom in user interface design, and any sort of interface design (be it an object, a screen, or an API), and it’s a useful one. I (and everyone else) enjoy using an interface that just behaves exactly like I expect. It makes me comfortable, and gives me confidence that the product is well-engineered. It makes using a product *gasp* enjoyable.
But there’s another side to the double-edged surprise sword: delight.
Delight is when you surprise a user by transforming something they take for granted (something they normally wouldn’t give a second thought, if a first) and transforming it into something that directly and noticeably makes their experience better. Delight comes from making the user take that second glance and thinking, “Wow. They thought of everything.”
Delight makes people tell other people about your product.
Delight makes people want to use your product again and again.
Delight makes your product stand out from your competitors.
Delight makes ordinary extraordinary.
Delight people.
Have thoughts? Leave a comment.
Yesterday I wrote that I am going to be learning drupal by developing an online user-generated marketplace. I’ve started the odyssey, and I’m ready to report on the progress I made in Day 1.
My References
Whenever I’m learning a new system, I drown myself in reference material. Here are the resources I’ve used so far that I’ve found the most helpful:
- Drupal Concepts is a list of common concepts to understand before getting started with Drupal. It is a must-read before you get started to avoid confusion.
- General Category is where I turned when I realized I didn’t understand the terminology many guides were using (which was almost immediately).
- Building a Website with Drupal is a series of blog posts I’ve found very helpful so far in getting started. It sometimes covers things in more detail than I need, but it’s aimed at an audience a little less tech-savvy than me.
- Top 10 must-have Drupal Modules is a top-10 list that’s actually useful. I’m currently using 7/10 modules listed here.
Features of the Marketplace
It’s time to decide what I really want the site to do. A “user-generated marketplace” is pretty vague as far as website requirements go, so I decided to list out some features I think I want. The ones with asterisks are crucial. Also, this list is tenative. I may add/subtract features at any time:
- * I’m going with the Envato method of payment, and a more traditional one. The user can upload some money into his/her account, and then will be able to buy things on the site without having to check out, or they can buy things the “normal” way with a checkout process.
- * Carry digital and physical goods
- Digital goods have an unlimited inventory, but the user has to pay before downloading.
- Physical goods have a limited inventory (I’m only allowing a user to sell 1 of any item at a time), and once the customer pays, the seller is notified
- Package tracking for all physical goods
- User profiles with pictures, bios, etc…
- * A category system for navigating through items for sale
- Buyer/seller feedback
- Rating of items (1-5 stars)
- Private messaging system
Now on to Drupal……
Installing Drupal and Some Modules
I’m not going to list every step of the install. There are plenty of places for that. Instead, I’ll note interesting tidbits and gotchas.
The install went through without a hitch. I had a basic site staring me in the face after only a few minutes.
Now it was time to start installing modules and getting some basic functionality going on. It’s amazing how much functionality you can get for “free” (no coding) using pre-made modules, and I haven’t even scratched the surface of the gazillions of them.
Here are the modules I’ve installed so far, and (if necessary) a brief description of why:
- CCK – Apparently, you always need CCK. Always.
- Views – I haven’t used it yet, but apparently it’s another essential
- Pathauto
- Admin Menu seemed convenient
- XML Sitemap because it’s never too early for SEO
- Token is needed by Pathauto
- Poor Man’s Cron because I am lazy
- Voting API is needed by Fivestar (below)
- Fivestar makes voting on things easy
- Location for entering where a physical item will ship from
- SMTP Authentication Support because PHP’s
mail() function wasn’t working and I didn’t feel like figuring out why
- A note on this one: I had to change line 246 to
require_once(drupal_get_path('module', 'smtp') .'/phpmailer/_acp-ml/phpmailer/class.phpmailer.php'); because the path was wrong originally
- Image
- Flag for flagging items
- Advanced Help because I’m a n00b.
That seems like a lot of modules to me, but then again they each serve a distinct purpose, and I haven’t had to code at all.
What I’ve Got So Far
I created two new content types: Digital Item and Physical Item, and added some custom fields to each. Right now, they contain all the data they should, and they are displaying on the front page, but the display is ugly, and I want a different front page.
But, without any code, I’ve created 2 item types, and added some sample items. I can vote on them, or flag them as somehow bad. I can comment on them, and view where a physical item will be shipped on Google Maps and the best part is….
I haven’t written a line of code!
What I’ve Learned
I’ve learned a lot already, and I haven’t even done much:
- Reading up on those first few references and figuring out what modules, nodes, taxonomies, blocks, etc… are has really helped my digest the rest of the help material.
- Every time you add a new field type, you have to go and edit the user permissions to allow an authenticated user to edit that field type. If you don’t, and you add that field to a content type, the user will not be able to use it when creating a new item.
- Always read the README.txt and the INSTALL.txt if there’s any even minor problem installing a new module.
Next Steps
I’m going to put off theming the site until I have all the functionality I want. I may get a pre-made template, but I’m not doing anything custom yet. Next up is creating user profiles and setting up the category system (taxonomy). Additionally, I may have to play around with views to start setting up the actual flow of the site.
Wanna tell me how much of a n00bcake I am? The comment section is all yours!
Once again I emerge from my hole and post another incredibly infrequent article with the promise of more frequent ones to come. But this time I have a plan… kinda.
I’ve discovered I have a medical illness. It’s scary and you probably have it without realizing it. It’s called “IDontKnowDrupal-itis” and it affects millions of Americans. But I’m here to do something about it, and you can ride along with me. I’m going to beat the disease, and so can you!
Over the next few days, I’m going to be jumping into Drupal head-first by creating a pretty elaborate user-generated marketplace site. “What’s a user-generated marketplace?” you head-scratching, non-banjo-playing people may ask? It’s sorta kinda like Craigslist, but not really. The best site to compare it to is a place like ThemeForest, or iStockPhoto. It’s a place where users can upload digital (or real, in the case of Etsy) content and sell it, with the owner of the site taking some percent of the gross sales. It’s a model that’s getting big, and it’s a not-too-simple (blog), not-too-complex (Google) type of site to start out learning a framework/CMS on. It’s going to have some pretty cool and unique features, too (I hope).
So stay tuned for lots of Drupaly goodness, and plenty of laughs as you watch me flounder about like a madman in a sea of sanity.
Got something to say? WELL NO ONE CARES! Except for me, so let me know…
This site’s been eerily silent for some time now. I always felt like I had some things to write about, but never felt like I had the time to write it even when I did, so the posts have fallen by the wayside. But never fear (I know you’ve been scared. It’s OK now) because hopefully they’ll start back in all their full awesomey goodness.
But on to my point… Read more
My story about misadventures and getting to Vail is live on DCSki.
It’s a humorous narrative as opposed to a dry (though still fascinating, of course) report, and features a possessed GPS unit, car crashes, a make believe conversation I had with myself, and – best of all – me!
I had a lot of fun writing it, and I think it’s a pretty fun read. You can check it out on the front page at time of writing, or at its permanent home.
Here’s the teaser:
Ah, Vail. The beauty, the splendor, the adventure. The snow is whiter, the sky is bluer, the mountains are bigger and the people are prettier. Numerous Firsthand Reports on DCSki have covered these aspects of Vail. But DCSki Columnist J.R. Patten veers off the beaten path to provide an unconventional look at Vail — or, more to the point, the misadventures of getting to Vail.
I hope you laugh, cry, and feel the irresistable urge to send me tons of money.
Feel free to leave comments on DCSki or here, whichever tickles your fancy. I think I’ll write a commentary about it soon, maybe. I’d like to, but it all depends on if the muse strikes (ie. smacks me in the forehead).
You can check it out on the front page of DCSki (at time of writing) or, at its permanent home.
Thanks for reading!
Now I’ve got to write one on Vail.
Here’s the start of a new series with an incredibly unique and totally innovative theme: Things I Hate. Anyone want to guess what it’s going to be about?
That’s right, things I hate. You’re a genius. It’ll be a nice place to let loose my bitter side…
Anyway, the first thing:
Sites that have video that starts playing automatically
Say What?
Remember back in the good ol’ days of “Web0.5″ (there will soon be a similar article on web “versioning”)? People used to have songs and sounds that played in the background when their pages loaded. I’m sure there are still some horrifying sites out there that still do it. (*cough* MySpace *cough*)
Playing video (and anything else that makes noise) on page load is the same thing. I despise it, and chances are if you do it, I’ll instantly close your page and never come back (not on purpose, anyway).
Why I Hate It
Let’s examine why auto-playing stuff in the background is moronic:
- Your page is probably open in the background – do you really think you’re the only page I’m viewing right now? Does your page really deserve to command my attention over the other pages I actually wanted to be paying attention to? Umm… NO. I opened it in the background for a reason. I wanted to read it on my own time… until I realized it played something when the page loaded. Now I’ll just close it and never go back.
- I probably have music playing – There’s this crazy new-fangled thing people do: it’s called playing music on their computer while they’re doing other things. Absurd, I know. But do you really think I want my favorite song interrupted by your stupid video? Umm… NO. If I want to see your newest uploaded video, I’ll click play myself, on my time. Which brings me to my next point…
- You’re not letting me choose how to view your site - This point is a bit of a catch-all. I want to view your site the way I want to view it. Don’t force me to view it your way. Your design should be good enough to suggest to me how I should view it, and to lead me to the most important things. You shouldn’t need to be so pushy as to leave me no choice but to view your stinking video.
Chances are, you want me to like your site (point 1). You probably want me to stay around a while (point 2) too. Guess what auto-playing crap on your front page does? No, really, hypothesize away. I’ll wait. Actually I won’t. Yay for asynchronous communication.
I’ll bet if you’re one of the people who needs to be reading this article, you guessed wrong, because you didn’t immediately remove the auto-playing video from your front page. So let me enlighten you…
It makes the first thought I have about your site a bad one (see point 1), and it makes me close the stinking tab (see point 2) because I don’t feel like finding the pause button, and I’ve realized that the rest of your site is probably just as bad or worse as the front page and is therefore not worth my time.
Here’s the fundamental issue (that’s why I’m making it bigger):
Asking the user to click play is not asking too much. If they want to see your video, they’ll click play. If they don’t, then you probably have much bigger problems, but certainly shouldn’t be forcing them to watch it!
So congratulations. By auto-playing crap on your front page, you have done the opposite of what you meant to and what you need to do to have a successful site. And in the process, you’ve achieved a near-perfect level of FAIL. You should celebrate.
Now go fix your page.
Anyone else hate this as much as I do, or brave enough to admit you think it’s a good idea? Leave a comment. That’s what they’re there for!
Yep. You can in fact believe your eyes. There’s a new theme. I said I was going to, and despite the vast odds Vegas bookies laid against me, the mobs of people trying to kill me, and the nuclear bomb dropped on my house, here it is: A new theme! It’s here in all its grey and blue and wooden glory.
“How’s it different?”, your ever-inquiring, but not so perceptive mind ponders. Well, let me tell you a story…
Read more
Just a quick update to let the vast hordes that read this blog know there’s a design update in the works. Also, the long-overdue portfolio section will be making its debut, and there will be a main page as well. No date set yet, but Photoshop’s running’ and the ideas are flowin’.