Categories
Development

Drupal 7 Only Display 1 Image in Teaser

ok, I was working with a content type with an image field that could hold multiple images (0-4 say). Using the Teaser view mode it would display all the images that were associated with that node, which was really cool in the Default view mode, but not so much the Teaser view mode. I only want it to display 1 image there.

So of course, there’s multiple ways to do this, but I found this approach to be the best for me.

I decided to create and edit an template file in this case since there was enough overall customization going on with this node to warrant such changes. So I created a template file name node–myContentType.tpl.php  based on node.tpl.php and stored in in my theme templates directory.

Easy enough. I then threw in there some crazy text just to make sure I was working with the right template file.

Then I just made the following edits to node–myContentType.tpl.php

if ($view_mode == 'teaser') {
  print render($content['myDemoImage'][0]);
} else {
  print render($content['myDemoImage']);
}

The if statement checks what view mode you are in, if it’s teaser which is the one I want to only display 1 image in then it just renders the first photo in myDemoImage field, else display them all.

That’s it, not too bad. Another reason why I do enjoy working with Drupal.

Categories
Development

visitavalonnj.com

visitavalonnj.comFinished up one of the cooler projects I’ve had the pleasure to work on a few weeks ago. The site is www.visitavalonnj.com.

I’ve worked with the client in the past and they were looking for a new site to help with the tourism of Avalon, NJ (a very nice place). Working with them is excellent and probably the best overall client relationship I’ve had to date. They know what that want, and present a professional design/concept and I build them a web solution to meet their needs.

In this case they really wanted a site that would be easy for them to maintain and add and edit content on a regular basis. Oh yeah, and they also needed it done before the start of their tourism season (middle of March ideally).

With only a few seconds into the conversation I knew that Drupal would be the perfect match for their needs.

Some modules featured in the creation of this project were:

  • Views – while I use it in every Drupal site I’ve ever worked on, it was heavily used in this project and really helped cut down on development time.
  • Calendar and Date – they needed an events calendar and the Calendar module was great to build upon. They also used dates with other content types and the Date module was a real life saver in these cases too.
  • Media – the client wanted the ability to add images inline view a wysiwyg editor. While still not a perfect solution, the Media module did help us give the client such a ability.
  • Facebook OAuth – they wanted users to have the option to login with their Facebook account instead of having to create a separate account for their site. This module was simple to set up and got the job done.
  • Google weather – this allowed us to easily bring in and display the latest weather in Avalon without too much hassle. Just some minor CSS tweaking was involved to get it done.
  • Social media – a very new module and it’s release was most timely. An excellent way to bring the now common social media button onto a website.
  • Webform – again a well known staple that just gets the job done.
  • Omega Theme – a real lifesaver for building a responsive web design. I highly recommend it as a starter theme for any new site.

The whole building block structure of Drupal really allowed us to deliver some cutting edge features without having to start from scratch. This really saved us a great deal in time and costs ($$$) and allowed me to concentrate more of the really unique aspects of the site.

Most impressive was how well the client has been able to use Drupal to manage the site. Our training simply consisted of a few minutes on a phone call. The admin interface was very intuitive to them and I did make sure to label all content types and fields so that each part was clear to them when it came time for them to manage the site.

Again, this was a pretty impressive project and and absolute treat to work with them again! I’m very impressed with it’s outcome and am very excited to check back with it’s performance in a few months.

Lots of fun.

Categories
Adventure

DrupalCon Denver: Day 2

Woke up really early (think the whole timezone thing must be messing with me a bit), so I figured I’d check out the gym in the hotel. Surprisingly, many others had the same idea. I got a nice super early workout to start off my day.

Then I walked over to the Colorado Convention Center which featured the opening keynote by Dries, the founder of Drupal. The theatre was massive, and much to my surprise it was practically packed with all the attendees. I’m really interested when they release the final count, it’s gotta be at least 3000+

Then the sessions began.

My first was Drupal Media. This is a very important module to practically all the sites I work with now. It was great to hear all about it and it’s features firsthand. I was pleased to hear of how much they’re committed to it and wil really try to chip in myself to this most noble cause.

Then we had lunch. Thousands were driven like cattle to the food upstairs. It was a lunch in a box (like the shoobies pioneered), and not too bad. In my box was a turkey sandwich (very good on some fine bread), a bag of chips, a big chocolate chip cookie and an apple which I wisely decided to save for later in the day (so glad I did just a few minutes ago). A fine box.

Then I went to my first ever BOF (birds of a feather) session. These are more group discussions than formal sessions. It was pretty cool, the topic was Drupal Trends in Education: Mozilla Badges, Learning Registry and Data.ED.gov. Everyone there seemed to be from education, so I had a good amount in common with most of them. The whole badge idea sounds very promising, but I can’t see the NJEA not somehow shooting in down in fear or something like that.

The Drupal Community: Where Are We Going and How to Get Involved was the next session. This had a much smaller attendance than most the other sessions, but the presenter webchick put on an excellent. The audience seemed very eager to contribute to the community and that’s a thing to see.

The next session, HTML 4S turned out to be much more interesting that I’d imagine it’d be. The presenter was a very animated, foul-mouthed Dane. He was hilarious, though there were times I didn’t quite understand what he said I still found myself cracking up. He was clearly very passionate about what he does, and had some excellent tips and suggestions regarding markup with a strong focus on HTML 5 today.

The final session of the day for me was Webform: The Survey Tool for Drupal. The presenter did a really great job, going over the basics as well as some advanced tips that I will surely put to use. I worried that it might be too basic before attending, but it was perfect and I’m glad that I did.

Then I headed back to the hotel and dropped my stuff off and headed out to grab a bite to eat. I’ll try to check out Denver a bit more tonight and see if there’s anything going on in the Code Lounge later tonight if I’m up to it.

Categories
Adventure

DrupalCon Denver: Day 1

Big Blue BearWoke up around 3:30 am or so to make sure that I had plenty of time to catch my 7:15 flight. I really didn’t have any trouble getting up (didn’t need the alarm clock), and didn’t feel tired driving to Philadelphia Airport either.

I’m not much of a Philly visitor, so getting to the airport is still an adventure for me. Luckily, no wrong turns were made and I got there in decent time. I’m not sure if this is a new thing with me or not, but I really didn’t feel comfortable driving over the bridge. I’ve driven over many a bridges in my day, but for some reason this morning it kinda creeped me out a bit. Perhaps I was more tired than I recalled, oh well.

The plane ride wasn’t too bad either. Flew on SouthWest, and we actually landed 45 minutes ahead of schedule. Apparently the wind was really down today, so that meant much less drag on the trip over. The flight wasn’t even close to full, so every seemed to be no more than 2 people per row.

There was a good deal of turbulence at times, especially as we approached Denver. I was told to expect that, so it didn’t spook me too much. By some miracle I hopped right onto a train at the airport and would up right at where my shuttle service was. Did not expect that to go so smoothly.

I then checked into the hotel, seems nice so far. As you probably can assume if you no me at all, by this time I was starving. So I took a walk to Sam’s No. 3, a place that I found on one of the Food Network shows.

Food was very good, portions were huge. I moved so that a couple could be seated. This turned out to be a most chivalrous act as the person I was now sitting next to was a toothless crazy talking bad lady. She said some pretty random stuff to me, and I do feel as though I will smell of cat for months.

I then proceeded to return to the hotel, with a few missed blocks along the way and took a much needed shower. I am very proud to state that Denver has decent water, and the hotel has great water pressure. This is most important.

Next I walked over to the Colorado Convention Center and registered for the conference. This place is massive. There’s even a gigantic blue bear statue looking into the place, very cool. Registration was a snap and I got a nice t-shirt to add to my collection.

I missed the cutoff date for the hack-a-thon (such a bummer), but did sit down and chat with some other great people with similar interests. It was great to exchange tips and tricks with them. I don’t have that day to day to do, so it’s always a pleasure to meet fellow geeks in person.

I also took in the shortened conference opening day to explore much of Denver. The 16th Street Mall was very nice. Tons of nice shops with a bus that runs the entire stretch for free (I of course walked the entire time).

I did treat myself to some frozen yogurt at Pink Berry. Got salty caramel with raspberries and blueberries. Yum. I pretty much walked around a lot today. Checked out the capital building and some park and walked in pretty much every store imaginable. It’s a pretty cool setup they have here.

I’m exhausted and probably falling early tonight to catch up on the poor sleep last night and have energy for the sessions I really want to check out. All the good stuff really starts tomorrow, and I’m really looking forward to learning all that fun stuff.

Categories
Development

Theme Fields in Drupal 7

This is so easy now that I know how to do it, but I didn’t realize that fields could be themed similar to nodes.

Just create a template file titled:

field–[field_name].tpl.php

Drupal 7 Content types

and save it in your theme’s directory:

/sites/all/themes/[your_theme]/

You can get the field name on the Content Type screen, Structure > Content types > [your_content_type]

Then you just enter your markup in the field–[field_name].tpl.php file that you’ve created.

You can use the field.tpl.php file located in /modules/field/theme/field.tpl.php as a starting point.

 

Categories
Development

Drupaldelphia 2011

DrupaldelphiaAttended Drupaldelphia at Alter Hall at Temple University today. I took the journey to Philly with Mark, he drove since he knows Philadelphia much better than I. He actually knew many facts about various buildings and areas.

The facilities at Temple were very impressive. Great sized lecture rooms, with 2 large screens and electrical outlets everywhere for everyone’s laptops. The wifi was also great too, didn’t have a single issue once I logged in.

All the sessions I attended were pretty solid too.

  • Open Academy: A higher education Drupal product for departmental websites
  • Keynote
  • Building a backend content administrators will love
  • Making Site Mobile Friendly
  • Ten Steps to Becoming a Panels Pro

Some very good and insightful stuff. Picked up some new tricks and gained confidence in some cases, knowing that what I had been doing in some cases is what was suggested as best practice too.

The mobile and content administration stuff were very relevant to some current projects I’m working on. So the timing couldn’t of been better.

Lunch was pretty amazing too. I wasn’t expecting much of anything, but it was really good. Just the right amount of food too. They also gave out free t-shirts too. So now I have another Drupal shirt.

All in all an extemely very well done event. Drupal continues to be an amazing platform. I’m so glad that I attended and definitely am looking forward to another one next year.