简体   繁体   中英

How can I customize COUNT nodes with css

I have a drupal view that show nodes title and nodes count. I got that node count from [contextual filters>content(type)>display a summary>display record count with link].

SQL query for that shows:

    SELECT node.type AS node_type, COUNT(node.nid) AS num_records
    FROM 
    {node} node
    WHERE (( (node.status = '1') AND (node.type IN  ('company', 'job')) ))
    GROUP BY node_type
    ORDER BY node_type ASC
    LIMIT 3 OFFSET 0;

And it appears like: Company(2) Job(4)

What I want to do is to customize COUNT(node.nid) with css. For example, change font-size of count,position of that count.

How can I customize that count with css?Or any other way to get that count?

Option 1
Override the template file for the views row.
In the views interface, under advanced, click Theme: information.
There you will find a list of the files that views looks for to theme styles, rows, fields etc. The one that is currently being used will be bold.
The default theme files are in the modules/views/theme/ folder.
You probably want to override the Row style output .
Create a file with one of the names suggested in the views theme information and put it into your themes folder, then copy and paste the code from the original views template file and alter it with what output you need.

A handy function to find what variables are available in a template file is get_defined_vars() . If you have the devel module installed, calling dpm(get_defined_vars()); in your template file will give you a nice way to see all the variables you can use in your template file.

Option 2
Click on Rewrite Results then Rewrite the output of this field in the field settings and add your html and use replacement patterns

Option 3 - probably the easiest
Hide the original fields and add a Global:Custom text field and add your html and use replacement patterns in the output.

Option 4
Override the template_preprocess_views_view_fields function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM