I want to show the submitted exposed filter data in the Views header/footer. This can be done by retrieving the $view object in PHP. The following code will printed the exposed filter data. Apply it to the Views header/footer with PHP enabled.
Continue reading Drupal – Show exposed filter value in Views header/footer
Tag Archives: Drupal
Drupal – Get taxonomy term by term ID
In Drupal 6, you can get the term object using the following function
taxonomy_get_term($tid);
Drupal 7 – Get number of nodes of Taxonomy Term in Views
About 2 months ago i published a post on how to get the number of nodes of a specific taxonomy term by term ID.
Drupal – Get number of nodes of Taxonomy Term by Term ID
Unfortunately, the taxonomy_term_count_nodes() no longer works in Drupal 7 but you can get the count by Views in D7.
Continue reading Drupal 7 – Get number of nodes of Taxonomy Term in Views
Ubercart – Get the product picture
You can get the product picture by the product node id using the following function
print uc_product_get_picture(<product node id>, 'cart');
you can use any other ImageCache settings by replacing the ‘cart’ parameter.
Done =)
Drupal – Check if user has logged in
The following piece of codes check if the Drupal visitor is logged in or not.
...
if (user_is_logged_in()) {
// user is logged in
} else {
// anonymous user
{
...
Done =)
Reference: Drupal API – user_is_logged_in
Drupal – Render a menu in View header or footer
You can render a menu in the header/footer of a view. Add the following code to either one of them.
<?php
print theme('links', menu_navigation_links(<menu id>), array('class' => 'menu <custom-class>'));
?>
Continue reading Drupal – Render a menu in View header or footer
Drupal – Show a node location with Google Map in Views
We could add location information to node using the Location module. If the GMap module is enabled, we could even show the location with Google Map in Views.
1. Download and enable the GMap module.
2. Edit the Locative information of any content type. Make sure the Coordinate Chooser is set to Allow. Continue reading Drupal – Show a node location with Google Map in Views
Drupal – $data->field_name problem in Views Custom Field
We have talked about using Views Custom Field which really makes Views more versatile. In the custom PHP field, you can get the data of other fields from $data. But the field names under the $data may changed later as you modify the view.
A workaround is to get the field data from $data using the field_id. Continue reading Drupal – $data->field_name problem in Views Custom Field
Drupal – Get CCK Allowed Value Label
We can create a CCK selection list or checkboxes field with a list of allowed values in key|value pair. normally when you retrieve a node content, what you get is only the key instead of the value.
Suppose we have a content type called Silly Question(silly_question) with a field called Option(field_option) which has the following allowed values. Continue reading Drupal – Get CCK Allowed Value Label
Drupal – Create Custom Module Admin Settings Page
Let’s create the admin settings page base on the example module we used in
Drupal – Introduction to Drupal Theming @ 3
In order to add the settings page, we need to add a new menu in in hook_menu() and the corresponding callback function which is ykyuen_admin() in this example. Continue reading Drupal – Create Custom Module Admin Settings Page