In this video we will take a look at the View that comes with the Twitter module. We'll check out the page that shows all tweets, use a contextual filter to view tweets by a specific user, and place the default tweets block in the sidebar.
We'll start out by taking a look at the tweets page.
Viewing Tweets From All Added Accounts
- Go to "/tweets"
Here we see the recent tweets from all of the Twitter accounts we've added. Let's take a look at the view that's creating this page.
- Click the "gear" icon
- Click "Edit view"
This view shows us that we are displaying an HTML list of fields. The "Twitter status message ID" is actually hidden, and we're just displaying the "Formatted tweet". One setting you might not notice it set under the "Advanced" section. If we click the dropdown, you'll see that we are using a contextual filter of "Login name" and if we click on that, we'll see that it's set to "Display all results for the specified field" when there is no context in the URL. And lastly, if we scroll down, we'll see that when the filter value is in the URL, the title is overwritten to "Tweets by @%1". So, this will say something like "Tweets by @ModsUnraveled" if "ModsUnraveled" were in the URL. Let me show you how that works.
I'll cancel out of this window, and cancel any changes to the view. This takes us back to the "/tweets" page.
Viewing Tweets From Individual Accounts
To view tweets from an individual account, we can simply append the Twitter handle to the URL.
- So, I'll go to "/tweets/ModsUnraveled" to view just my tweets.
And voilĂ ! It works! So, you can use this to create links to individual user accounts if you'd like.
Displaying a "Latest Tweets" Block in the Sidebar
Lastly, you might have noticed that there was a "Tweets Raw" display, and a "Block" display when we edited the view. Let's take a quick look at those, and then display the block in the sidebar.
- Click the "gear" icon
- Click "Edit view"
- Click the "Tweets Raw" display
This view is not used anywhere by default, but gives you an idea of the individual parts of a tweet that you can use. If you scroll down to the live preview, you can see it in action.
- Click the "Block" display
This simply shows the "Message text" and the "Created time" (in the "Time ago" format), so there's nothing special here. It's much like the Tweets page, but in block form. I'm going to tell it to only show the latest 10 tweets, and then place it in the sidebar.
- In the "Pager" section click "Display all items"
- For: This block (override)
- Select "Display a specified number of items"
- (Apply (this display))
- Items to display: 10
- (Apply (this display))
- (Save) (Save the view)
Now, let's display the block in the sidebar to see it in action.
- Go to "Structure => Blocks" (admin/structure/block)
- Block: Tweets
- Region: Sidebar second
- (Save blocks)
Now, we can go home, and we'll see the block in the sidebar. That looks good to me, so, we're all set!
In the next video, we'll install and configure the ShareThis module so that site visitors can easily share your content on their networks.