How can I customize COUNT nodes with css - 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.

Related

Drupal - Edit Views Selective Filters module to rename the option tag

Actually, I try to make a filter criteria who list the available "structures" in my view. I'm using the Views Selective Filter module who does what I want. But in that list, that show the id of my structure and not the name. (I can't show you with an image, actually)
I want that my "structures" name replaces the id in my list (but not the value).
If you have any idea, I would be very grateful.
I found a solution.
I have edited the Views Selective Filter module to allow him to detect and load my structure name.
After that, I just have to change the text of my option before that the id has assigned in.

how to change a drupal views output

I need to create a block with eg the latest comments on the site.
when using views, concegui select the data I wanted, but the problem is that I need to edit the output of view (specify the html). I tried to make a tpl, but the fields when they get to this, are already formatted ([#markup]). also tried to make a block programmatically by accessing the fields of view, via $comments = views_get_view('last_opinions');, but so the fields do not bring content, but for example, ids (for referrals), or integers (in the case of dates), ....
basically, how to change views output?
views->your view->advance(third panel)-> Theme: Information -> click Information ->choose tpl as per your requirement and find $row which actually prints your output

Drupal 7: Displaying nodes by grouping them based on a field

Is there a way to group nodes based on a node reference field and display them in a list.
Say, I have a content type Album, and nodes Album ABC and Album DEF of type Album. These are referenced in nodes of content type Track. How can I display all the albums with the referenced Tracks in which they are referenced as a list?
For example:
Album ABC
Track 1
Track 2
Track 3
Album DEF
Track 4
Track 5
Track 6
and so on.
I have been using Drupal only for a few weeks now, Can anyone explain the answer given below??
Thanks.
Create a view filtering on the node type = album
Set the view output style to "HTML List"
Include the node reference field as a link to node in your field list
Click "theme information" then look at the name of the file that applies to the node reference field. Create a .tpl.php file with a candidate name that's specific enough for your needs will be something like views-view--viewname--fieldname.tpl.php. Click the link for the template file in use in theme information for this field, and views will show you the code in that file. Copy & paste that code to your new file
In the new file, you'll want to write a little PHP to output your links as a list. If you enable the devel module, put in the page, and inspect what's available. One of them will be an array of links. Output that with
Try Field Group or Display Suite.

Drupal: re-use same CCK Field in the same content type

I need a sequence of text, image, video CCK fields, repeated twice in my content type.
I need to create 2 different groups (I don't want to use multi-upload functionality).
I was wondering if I have to create a new field Image - File Upload for the second group, or I can somehow to re-use the first one (which is already added, and I would like to add it twice in the second group as well).
thanks
Enable Content Copy module from CCK package. It provides CCK fields import/export functionality.
I've solved by creating 3 groups, and creating image1, image2, image3... video1, video2, video3, and text1, text2, text3 CCK fields. Any order is now possible.

Changing the Admin Theme in Drupal 6 Directly in Database

I'd like to restore the default admin theme in Drupal 6 via the database. Anyone know where this is stored?
Btw, there is a great answer describing how to change your site's public theme in the database here ...I just could not get it to update my admin theme.
List of themes you can find in {system} table, filter by type = theme, there you can set status = 1
Default theme you can find in {variable} table, filter by name = theme_default, change it to you theme name, as it is written in system table (for example, garland, not Garland).
After this clear cache table.
Follow these steps via the db:
{system} table, filter by type=theme
set status=1
{variable} table, filter by
name=theme_default change it to you
theme name, as it is written in
system table
{variable} table, filter by
name=admin_theme change it to you
theme name, as it is written in
system table. Do not skip this step.
truncate cache
Login to your phpMyAdmin, click on SQL tab and run:
UPDATE system SET status=1 WHERE name = 'garland';
UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
TRUNCATE cache;
Note that you may need to add prefix to your tables
Thanks to https://drupal.org/node/200774
If you're editing the variables in PHPMyAdmin, remember that you're editing a serialized value. This means that the value you're editing looks something like this: 's:7:"garland"'.
If you just changed "garland" to "marvin" that would change the number of letters in the serialized value from seven to six.
You'd need to change 's:7:"garland"' to 's:6:"marvin"'
That is, you'd need to count the number of letters in your new theme, and update the number following s: accordingly.

Resources