Purpose :
add a class name called 'test-row-class' in the div of each row of drupal view
Solutions :
There are two ways to do it. First, add the class via drupal admin; Second, customize view template file named 'views-view-unformatted.tpl.php'.
Via Drupal Admin:
- Find the machine name of view using 'Theme Developer' module. Enable the module, click the view you want to modify on the web page, and clieck the views_view on the pop-up window of 'Theme Developer'. After that, the machine name called 'price_location' can be found in the 'candidate template files' part
- Search the machine name of view in the database table of 'views_view' and get the 'human name' of view which is 'Theme Price Location Sidebar'
- Go to drupal admin page of 'admin/structure/views' and search the 'human name' of view. And then click edit of the specific view.
- Switch to the display block that needs to be changed
- Click the 'Format: Settings' in the 'FORMAT' section
- Add the class name whichever you want in the input of 'Row Class' and the class name will show up on the front page. Here using 'test-row-class' as an example.
Via Modifying Template Files:
- Enable 'Theme Developer' and click the view that needs to be change on the web page
- Click 'views_view_unformatted' which is the descendant of 'views_view'. ('views_view' template is the top template file, while 'views_view_unformatted' is the template file displaying the rows of the view elements). And then the candidate tmeplate files will show up.
- Choose one of the candidate template files you want to use. Here will take the most specific template file name of 'views-view-unformatted--theme-price-location--theme-price-location.tpl.php'.
- Create the template file in the currently used theme folder and copy the code from 'views-view-unformatted.tpl.php' which is the default template file
- Change the code in the specific template file as you want and it won't affect other views