Everyone knows that the taxonomy module allows one to categorize your content using both tags and administrator defined terms and is very flexible for classifying content. You can create one free-tagging vocabulary for everything, or separate controlled vocabularies to define the various properties of your content.
By using views in conjunction with taxonomy, one can easily create a block of related content.
For example on www.OyeStyle.com, we have articles categorized by one vocabulary called as "Main" and another vocabulary called as "Subcategory". These contain a fixed set of terms. We also allow a taxonomy with free-flowing tags for that much more flexibility and further categorization.We wanted to show a block of related articles based on the taxonomy on each page and of-course views was the answer. The link here at http://drupal.org/node/65375 details out as to how to go about it for D5 and D6.
However due to the free-tagging entries, we were ending up with a long list of articles diluting the "meaning" of related content in some ways. Here is how you can pick up related content by using specific taxonomies by avoiding free tags:
After following the instructions above in the drupal link, go to your view and edit the "Taxonomy: Term ID" argument. We then need to modify the PHP code specified for the default argument handling. Modify it thus:
$node = node_load(arg(1));
if ($node && $node->type == 'article' && $node->taxonomy) {
foreach($node->taxonomy as $term) {
$vocab = taxonomy_vocabulary_load($term->vid);
if (empty($vocab->tags))
$terms[] = $term->tid;
}
return implode('+' , $terms);
} else { return; }
The key difference in the above code is that for each taxonomy term associated with the node, we are getting the vocabulary associated with it . We then check if this vocabulary allows free tagging and ignore it if so (the empty($vocab->tags) check does this). Do not worry about the performance implications here, the vocabulary will most probably be cached across future calls. One can possibly do other modifications to the above code. For example, lets say you only want terms from a specific vocabulary. That can be done by:
$specific_vocab_name = 'Main';
$vocab = taxonomy_vocabulary_load($term->vid);
if (strtolower($vocab->name) == strtolower($specific_vocab_name))
$terms[] = $term->tid;
The above code will only pick terms belonging to the 'Main' vocabulary.Basically modify the vocabulary checks appropriately to get the desired results.
I hope this was useful. Check out the working functionality on Oyestyle by browsing through the articles there! :)
Showing posts with label oyestyle. Show all posts
Showing posts with label oyestyle. Show all posts
Friday, December 17, 2010
Monday, October 11, 2010
CDN with Drupal and Parallel module
Am getting good exposure to Drupal land and am loving it so far. I have to be hands on for my work and that is the best way to gain knowledge and expertise - be hands on, nothing beats it!
The current speed of www.oyestyle.com is pretty good, but I wanted to be armed for the day we hit bigger numbers :), so I was testing out the possibility of using a CDN to serve out the static javascript, css and image stuff on the site.
First, I also looked at some Indian CDN offerings. Obviously if the data is being served from close to India, it will help the target audience. But both Airtel and Tata offerings seem to be out of the reach of people who are just starting out. I also checked out the Marcellus guys, but they seem to specialize only in videos. Am thinking and looking at MaxCDN guys currently.
Anyways, the article is about setting up a CDN quickly. For this, we are planning to use the Parallel module. It is not strictly a CDN module per se, but what it does is that it allows you to specify [sub]domains that you can use for your js/css/image files. The page preprocessor code then replaces all references with those domains. This is all you need to do to set it up!
If you have a pull-based CDN like MaxCDN on the other side, then you do not have to upload any files to it too. If it cannot find the file, the cdn will fetch it from my server and then serve it from then on. It will handle this transparently! Will get back with my experience soon :)
The current speed of www.oyestyle.com is pretty good, but I wanted to be armed for the day we hit bigger numbers :), so I was testing out the possibility of using a CDN to serve out the static javascript, css and image stuff on the site.
First, I also looked at some Indian CDN offerings. Obviously if the data is being served from close to India, it will help the target audience. But both Airtel and Tata offerings seem to be out of the reach of people who are just starting out. I also checked out the Marcellus guys, but they seem to specialize only in videos. Am thinking and looking at MaxCDN guys currently.
Anyways, the article is about setting up a CDN quickly. For this, we are planning to use the Parallel module. It is not strictly a CDN module per se, but what it does is that it allows you to specify [sub]domains that you can use for your js/css/image files. The page preprocessor code then replaces all references with those domains. This is all you need to do to set it up!
If you have a pull-based CDN like MaxCDN on the other side, then you do not have to upload any files to it too. If it cannot find the file, the cdn will fetch it from my server and then serve it from then on. It will handle this transparently! Will get back with my experience soon :)
Subscribe to:
Posts (Atom)