• Home
  • About
  • Contact
  • Advertise

Devlounge

Design, Develop, and Grow

ateşli sevgilisi fantezisini yaşamak istediğini söyler porno ona arkadaşları varken onunla gizli saklı seks yapmak istediğini sikiş söyleyen kız hafta sonu için gelen arkadaşının görmediği bir sikiş açıdan sakso çekmeye başlayınca adamın yarağını bu altyazılı porno şekilde indiremez ve açık şekilde salonda sikişimeye sex izle başladıklarında misafir kızı da bu sekslerine rokettube konuk ederler seks yapacağını düşünmeyerek onun sex izle oyun oynadığını zanneder sabah olur ve herkes uyanır hd porno bu sırada yanında şişme mankenini de getiren sapık erotik hikayeler genç sınav haftası ders çalışan genç adam üvey annesinin sikiş eve gelmesiyle hayatının şokunu yaşar

  • Home
  • Code
  • Design
  • Design Focus
  • Interviews
  • Publishing
  • Strategy
  • Webapps
  • Extras

How to Make a Magazine-Style Homepage with Drupal, Pt 2

November 3, 2008 By Dustin Boston

In part one of this three part series we laid the foundation for a magazine-style home page in Drupal. This week we are going to get our hands dirty by digging into CCK and Views. Get out your pocket protectors, this one is a little geeky!

Vocabulary settings

The first thing you will need to do is make sure that the Story content type has the two vocabularies that we created in part one. Go to Content management » Taxonomy and click on the edit vocabulary link next to Categories. Select the Story checkbox under content types. Next, check the Multiple Select checkbox below Settings. You can clear the other checkboxes in this section. Now hit save and move on to the Tags vocabulary.

The Tags vocabulary also needs to be available to the Story content type. Under settings, select both the Tags and Multiple Select checkboxes. This will allow us to free-tag a Story.

Extending Content Types with CCK

In order to take advantage of the ImageCache module you will need to extend the Story content type with CCK. At the very least, you will need to add an Image type field. If you ever use Creative Commons licensed photography you will want to credit the Author and Source. It can be useful to add these as fields so that you do not have to remember a special format every time.

Add the following fields to the Story content type by going to Content Management » Content Types and then clicking the Manage Fields link next to Story.

Label Field Name (prefixed field_) Type of Data to Store Form element to Edit Data
Image image Image Image
Image Author image_author Text Text Field
Image Source image_source Text Text Field

Toward the bottom of the page, you will see several input boxes. In the New Field section, enter the settings in the table above. Views will automatically prefix the field name with field_, so you do not need to include that part.

After you hit save there are, only two things that you need to configure on the next page. If you prefer, you can configure the Path Settings to put uploaded images into a subdirectory. I like to get clever here and put my images in a directory called—you guessed it—images! The other optional setting is the ALT text. Be nice to your disabled users and select this box. Finally, save the field settings.

Add the Image Author and Image Source fields using the data in the table. The options are up to you. I like to limit the amount of text that can go into one text box to 255 characters. That is all that you need to configure for Content Types. Next up is the hard part, creating the views that will display the content on your homepage.

Creating the views

Views seem to be one of the most powerful and yet most confusing modules there are. The overhauled Views module looks good but I found it startling at first. There is a LOT that you can do with it.

If you are feeling lazy you can just import the views by copying the export code provided and then pasting into the form under Site Building » Views » Import. Imports do not usually work well for me, so you are on your own.

Warming up with the headline view

The headline view will display a single post with a nice big image. This is for your most important stories only. Go to Site Building » Views » Add. The View name should be “Headline” and the description can be anything you would like. I used “Display a single post teaser and medium size image in the Headline category.” A tag is optional but may help you find your views quicker if you have a lot of them. Finally, select the Node View type and press the Next button.

On the next page, you will begin to configure the view settings by selecting the Block display type from the drop down. Next, click the Add Display button. Views will create a new display type that uses the default settings. You will only need to configure the Basic settings, Fields and Filters for the headline view.

You can change each of these settings by clicking the setting’s link or gear icon. Views will display the configuration options below the settings. The tricky thing about the configuration options is that you have to look for the Override button on the right side of the editing area. Because you did not set any default values, you will usually want to override the setting by clicking this button. Remember to click the Save button or your changes will be lost.

Configure the Headline view with the following settings:

Basic settings
  • Name: Headline
  • Title: None
  • Style: Unformatted
  • Row style: Fields
  • Use AJAX: No
  • Use pager: No
  • Items to display: 1
  • More link: No
  • Distinct: No
  • Access: Unrestricted
  • Exposed form in block: No
  • Header: None
  • Footer: None
  • Empty text: None
  • Theme: Information

To set the Fields you will need to click the little + icon beside the Fields header text. You can use the drop down to display only relevant Fields but I have found that it is just as easy to scroll through the list. You will need to select the following fields and then click Add.

Fields
Field Notes
Content: Image: Image (field_image) Label: none
Format: medium image linked to node
Node: Teaser No additional configuration required
Node: Title Check Link this field to its node
Filters
Field Notes
Node: Published True
Taxonomy: Term Vocabulary: Categories
Selection Type: Drop down
Operator: Is one of
Select terms from vocabulary Categories: Headline

Remember to click the Save button!

The Features View

The features view displays three excerpts each with their own thumbnail image. You will configure it to show the three most recent stories marked as a Feature.
Basic settings

Basic settings
  • Name: Block
  • Title: Features
  • Style: List
  • Row style: Fields
  • Use AJAX: No
  • Use pager: No
  • Items to display: 3
  • More link: No
  • Distinct: No
  • Access: Unrestricted
  • Exposed form in block: No
  • Header: None
  • Footer: None
  • Empty text: None
  • Theme: Information
Fields
Field Notes
Content: Image: Image (field_image) Label: none
Format: thumbnail image linked to node
Node: Teaser No additional configuration required
Node: Title Check Link this field to its node
Sort criteria
Field Notes
Node: Post date asc
Filters
Field Notes
Node: Published True
Taxonomy: Term Vocabulary: Categories
Selection Type: Drop down
Operator: Is one of
Select terms from vocabulary Categories: Featured

Remember to click Save!

Posts by Category

This view is a little tricky. It will display the last five posts for each category. The difference is that you will not add the view to a region. Instead, you will hard-code the calls to it in the front-page template file. Add a new view called posts_by_category with a display type of Node. You can just use the default display type instead of creating a block.

Basic settings
  • Name: Defaults
  • Title: None
  • Style: List
  • Row style: Fields
  • Use AJAX: No
  • Use pager: No
  • Items to display: 5
  • More link: No
  • Distinct: No
  • Access: Unrestricted
  • Exposed form in block: No
  • Header: None
  • Footer: None
  • Empty text: None
  • Theme: Information
Arguments
Field Notes
Taxonomy: Term Action to take if argument is not present: Display all values
Validator:<Basic Validation>
Action to take if argument does not validate: Hide view/Page not found (404)
Fields
Field Notes
Node: Title Check Link this field to its node
Filters
Field Notes
Node: Published True

Smooth Sailing

If you made it this far, you have done well. The good news is that was the hardest and most tedious part. It is smooth sailing from here on out. Next week we will wrap up the series by themeing the views and adding some CSS to spruce things up.

View Import Files

  • Headline View
  • Features View
  • Posts By Category View

How to Make a Magazine-Style Homepage with Drupal, Pt 1

October 22, 2008 By Dustin Boston

Magazine style layouts are a great way to organize a lot of content on your home page. But do you know how to do it in Drupal? Over the next few posts, I will walk you through the process of creating a great looking home page much like what you see on many of the major news and magazine sites.

I will be using Drupal 6 and a handful of common modules. Unfortunately, many of the modules for Drupal 6 are still in development. Do not be surprised if you run into some little bumps. You should have some experience with the Views and CCK modules, some experience with themes, and a decent knowledge of CSS, XHTML, and PHP.

For now, I am going to focus on three main sections that are characteristic of most magazine style sites.

  • Headline story with a teaser and large image
  • Several featured stories with teasers and thumbnail images
  • A list of recent post titles by category

Once we have completed the series, you should be able to add other common elements on your own.

Install modules and themes

For this to work, you will need to download and install the following modules:

  • CCK (Content Construction Kit)
  • FileField
  • ImageAPI
  • ImageField
  • ImageCache
  • Views

RootCandy is a very nice admin theme I am using the Framework theme for the front-of-site, and RootCandy as the admin theme. These are optional but it will probably help to have at least the Framework theme installed.

Install everything as normal. Remember to put your themes and modules in the /sites/ directory. Here are the important settings you will need.

Automatically size images with ImageCache

Create three presets named Large, Medium, and Thumbnail. They should all use the Scale and Crop action. I used these dimensions:

ImageCache Preset Dimensions
Namespace Width Height
Large 640px 640p
Medium 350px 350p
Thumbnail 100px 100px

Later on, we will use a CCK field to upload an image and attach it to a story. The ImageCache module will automatically scale and crop your image to the dimensions you set.

Use WordPress style Taxonomy to keep things simple

The best Taxonomies are simple. We can all learn a lesson from WordPress when it comes to organizing our Vocabulary and Terms: keep it simple.

Set up a Vocabulary called “Tags” that allows you to free-tag to your heart’s content. Then set up a Vocabulary called “Categories” and add these terms:

  • Headline
  • Feature
  • Category 1
  • Category 2
  • Category 3
  • Category 4

Feel free to replace Category 1-4 with something more suitable to your content. I have a feeling that this Taxonomy structure is probably suitable for 95% of the world’s websites—but that is debatable.

Create regions

Now that we have finished configuring the modules, we can get our hands a little dirty. The first thing you will need to do is open up your front-of-site theme directory (Framework). Next, copy the page.tpl.php file and name it page-front.tpl.php. Drupal will automatically use this file as the template for the home page.

This is the generic code for a region:

[php]
if ($the_region) {
print ‘

‘;
print $the_region;
print ‘

‘;
}
[/php]

The variable $the_region can be anything you choose, but it must be defined in the theme’s .info file. The region definition looks like this:

regions[the_region] = My Region

the_region corresponds to the variable that you defined in the code. “My Region” can be whatever you choose to name that region. Create the following regions in the .info file, somewhere near the bottom:

[code]
regions[headline] = Headline
regions[features] = Features
[/code]

If you try to view your site, it should break. That is because we are overriding the default regions (sidebars, content, header and footer) that Drupal recognizes out of the box. We will need to redefine the default regions. You should now have something like this:

[code]
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[headline] = Headline
regions[features] = Features
[/code]

The last step in this part of the series is to add the regions. Find the main content area of your template and add this code:

[php]
print ‘

‘;
if ($headline) {
print ‘

‘;
print $headline;
print ‘

‘;
}

if ($features) {
print ‘

‘;
print $features;
print ‘

‘;
}
print ‘

‘;
[/php]

I added the main div and the region classes to make it easier for styling later on. Otherwise, they are not required.

Part 1 Wrap-up

That was easy. Our theme is now fully receptive to most of the content that will go on the home page. Apart from installing some modules and doing some very basic configuration, we were able to lay the foundation for a magazine style home page with just a little code.

In the next part of the series, we will enhance the Story content type with CCK and create several Views for displaying content.

Code & Tutorials

Which Front-End Development Languages Will Grow in 2017?

Your Guide to Leveraging APIs as a Developer

Bitcoin Processing Website Integration For Web Developers

Website Security For 2016 That All Developers Need To Know

5 Reasons You Need to Be Using jQuery

About Devlounge

Want to read more about Devlounge, or maybe you want to contact us, or even advertise? Oh, and don't forget to subscribe to updates!

The Best of Devlounge

Should You Start a Business or Remain Independent?

Search