I am a newbie in drupal.
How can i create a year listing of hyperlinks like this :
2012 2011 2009 2008
of blog posts published within any year and then link them to a page to diplay a teaser listing of blog posts within that year
I have views module installed and using contextual filters for year. I would like to use PHP code to get result set from view in the templates.php file and pass the results to my template.
Then I need to build some url alias for diplaying the particular template .eg. site_url/blog/2012 should display my template.
Please note : I already have a template for site_url/blog as the blog landing page template
Please tell me if thats feasible and how to do that?
You can use Drupal's built in taxonomy module for this. Go to the taxonomy page by going to admin->structure->taxonomy
.
In there you can create a new vocabulary called Year where you can enter as many or as few years as you like.
Then in your blog post content type create a new field called year and link it to the vocabulary by selecting term reference as the type and following the instructions from there.
If you wanted you could build a module that adds new years to the vocabulary automatically but that's a whole different question.
To then show only posts with that year in you can build a view. Install the Views module and go to structure->views
and add a new view to show content of type Blog Post. You can then set a contextural filter in the advanced tab to show ones tagged with the year. Then you can expose the filter so the user can change the year and you should be set.
NOTE: The view needs to be a page rather than a block for this to work.