CSS theme the drigg node list based on the "action" : upcoming, archive & popular

PGiro - October 13, 2008 - 11:16
Project:Drigg
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:philbar
Status:needs work
Description

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 ?

#1

PGiro - October 13, 2008 - 11:17
Title:CSS theme the dirgg node list based on the "action" : upcoming, archive & popular» CSS theme the drigg node list based on the "action" : upcoming, archive & popular

#2

mercmobily - October 14, 2008 - 10:32

Hi,

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.

#3

PGiro - October 14, 2008 - 20:04
Status:active» needs review

Sure.
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...)

AttachmentSize
actiondiv.patch 609 bytes

#4

mercmobily - October 15, 2008 - 16:02

Hi,

Anybody else: please test it?

Merc.

#5

philbar - June 4, 2009 - 07:34
Status:needs review» needs work

Isn'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.

#6

philbar - June 5, 2009 - 04:57
Assigned to:Anonymous» philbar

#7

mercmobily - June 5, 2009 - 05:43

Hi,

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.

#8

philbar - June 5, 2009 - 21:27
Version:5.x-1.x-dev» 6.x-1.x-dev
Category:support request» feature request

Merc,

Could use some help with using drupal_is_front_page.

#9

mercmobily - June 6, 2009 - 02:09

Hi,

Not following you :D

Merc

 
 

Drupal is a registered trademark of Dries Buytaert.