Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Dec 2007 at 10:30 UTC
Updated:
10 Sep 2010 at 23:26 UTC
I created a view sorted accorded to the Node:Sticky criterion.
However, in the output, I don't find any way to distinguish sticky nodes from non-sticky ones. Is there a way to tag sticky nodes with, say, a class='sticky' attribute?
Comments
Comment #1
ablivio commentedThe answer was quite simple: check the $node->sticky attribute in node.tpl.php, then add the relevant tagging in the HTML output accordingly.
Comment #2
Medya-1 commentedi am trying to do the same would you please help me i am kind of noob in this
Comment #3
jfall commentedHere are some more details for Medya...
In your theme, look for node.tpl.php, near the top you should see some theming code like:
This is printing out the div tag, which should look like:
for sticky nodes. Use View... Source in your browser to see what the node div looks like.
Now you need to add some CSS to style the div, for example
to put a light grey border around the node.
This is a good example of how theming works in general - Drual sets some variables (e.g., $sticky), or you set them yourself in template.php; you use these variables to format your HTML using one of the template (*.tpl.php) files; then you style the html with css.
hope that helps - good luck.
Comment #4
Medya-1 commentedjfall thanks for your reply...I have already tried to do that. I am using views for frontpage..and if I select a story as sticky it is listed on the top but no class is assigned so the class is same a others :(
Comment #5
Medya-1 commentedi think it does not print the div sticky tag for table view i have changed it to teaser list and it prints out the sticky tag..but i need it for table view
Comment #6
jfall commentedThat would have been useful information ;-)
So, you want an id added to rows in the table that contain a sticky node?
You probably need to override the theme_views_view_table function in your template.php file - but maybe I'm missing something (I did have a look, and as far as I can tell, Views does not look for the stick attribute when building the table data).
Perhaps you might try opening a new support issue for your specific issue (theme sticky nodes in table layout), as this thread is slightly different, and is a closed issue, so won't get much traffic.
good luck. You can contact me through my contact form if you want help with this.
Comment #7
marashi commentedI had the same problem and I fixed it as follows:
1- create a page for your view ... here is a page for 'block display' of a 'News' view.
views-view-fields--News--block-1.tpl.php
2- put it in this folder:
sites/all/themes/YOUR_THEME/views/
the content of this file is something like this
by putting this snippet of code
<?php if ($row->node_sticky) { print ' sticky'; } ?>it recognize whether this is a sticky node or not ... if so, it adds the sticky class to your code and then you can add some styles.
3-clear the cache
4- that's it.
Comment #8
errand commentedsolution for D6.16 + views 6.x-2.10
hello everyone. this how i did for my table style view:
1. go to http://drupal_site/admin/build/translate/search
find: Sticky
replace to Sticky
2. in your view add field: node:sticky > /sticky
use CSS to set your .field_sticky span style
this how it looks http://scraft.ru
i hope my english no so bad )))
i loveD6.xx