Hi,
I want to have a different background color for my node lists depending on whether the user is displaying "upcoming" or "popular". I haven't found a way to do that with the current way things are done : there is, as far as I can tell, no difference in display both lists, only the data is different.
I suppose a simple solution would be to encpasulate the list of nodes created in drigg_ui_node_list() with a div holding the action sort of like this:
$output = '<div class="'.$action.'">'; // ADD DIV HERE
// How many items to be shown in each page?
if(variable_get('drigg_hide_archived_menu',FALSE) && $action == 'archived'){
$items_per_page=150;
} else {
$items_per_page=variable_get('drigg_items_in_main_page', 20);
}
// Scan through the results
$result = pager_query(db_rewrite_sql($query), $items_per_page,0,NULL,$query_vars);
if (db_num_rows($result)==0) {
drupal_set_message(t(variable_get('drigg_no_items_to_display', 'No scoop available!')));
} else {
while ($node = db_fetch_object($result)) {
if($action == 'archived' && variable_get('drigg_hide_archived_menu', FALSE)){
$output .= '<p> '.l($node->title,'node/'.$node->nid).'</p>';
} else {
$output .= node_view(node_load($node->nid), TRUE);
}
}
}
$output .= theme('pager', NULL, variable_get('drigg_items_in_main_page', 20), 0);
$output .= "</div>"; //END DIV HERE
Then I can theme based on the containing class
What are your thoughts ? Any better way ?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | actiondiv.patch | 609 bytes | PGiro |
Comments
Comment #1
PGiro commentedComment #2
mercmobily commentedHi,
You are totally right, I think there should be a div around them.
Are you able to code?
I am especially interested to know if the default theme breaks if we add the divs. Can you give it a try and let me know?
If nothing gets broken, I shall add the div!
Merc.
Comment #3
PGiro commentedSure.
I've attached a patch against drigg_ui.module version 1.35. You need to apply the patch directly in the drigg_ui directory.
I've tested it on the stock drigg theme and it works fine, can someone else test it ?
Philippe
aka watcherFR (changed my nick...)
Comment #4
mercmobily commentedHi,
Anybody else: please test it?
Merc.
Comment #5
philbar commentedIsn't this the point of having the voting form change from light blue to yellow when the scoop has been promoted?
Anyhow, I test the patch. It works fine, except on the homepage. It cannot determine that it is "Popular" from the $action.
Comment #6
philbar commentedComment #7
mercmobily commentedHi,
Phil, what does $action contain for the home page? It really should be "popular" as well...
I am a bit lost on this one. But in general I agree on the Div as long as it doesn't break the theme.
Merc.
Comment #8
philbar commentedMerc,
Could use some help with using drupal_is_front_page.
Comment #9
mercmobily commentedHi,
Not following you :D
Merc
Comment #10
drupalina commentedThanks. the code in the original post worked for me in 5.x. In the patch I think you forgot to insert ">" in
$output = "<div class='drigg_$action'";I tried to do the same kind of theming for the Sections bar (i.e Categories), but it didn't work, maybe because $action is not declared in that function. Did anyone try that and get it working?