How to make Popular and Upcoming links and sub-links themeable?

drupalina - March 20, 2009 - 08:57
Project:Drigg
Version:5.x-1.36
Component:User interface
Category:feature request
Priority:normal
Assigned:philbar
Status:active
Description

Here's a question, which I'm sure many other Driggers would love:

does anyone know how to make those Popular (with its sub-links) and Upcoming (with it's sub-links) links themeable? I mean so that *Popular* (and it's children "newest", top7days, top30days etc) appear in Blue background and *Upcoming* (together with it's children "newest, oldest most_poppular, least_popular) appear in Grey background. To see what I mean visit www.Digg.com and see how the colours of the menu change when you click Upcoming and a Popular.

Also, since Drigg is so smart as to tie Sections with Upcoming and Popular links, I wonder if the background of the Sections could also be themeable depending on whether we are vieing Popular or Upcoming. So, if we are viewing Popular, then the sections would appear in Blue background. And if we are viwing Upcoming them sections would appear in Grey background.

I suspect that the theming tags are inserted in drigg_ui.module

Would anyone be kind enough to lend a piece of advice or code?

#1

munikho - March 21, 2009 - 10:27

Don't know about theming tags, but you could just do it with jquery and css.

$('.drigg-viewtype li:last.active').parents('#content').addClass('upcoming');

This only works if archives is turned off.
From here i guess you can use some css to change the background and stuff.

Good luck.

#2

drupalina - March 23, 2009 - 10:19

Hi Munikho,

thanks for the jquery line, But where exactly do I add it?

I mean between which lines?

#3

munikho - March 24, 2009 - 10:17

I was assuming you had an external javascript file. If you don't, you can also just load it in the head of page.tlp.php file like this.

<script type="text/javascript">
$(document).ready(function(){
   $('.drigg-viewtype li:last.active').parents('#content').addClass('upcoming');
});

</script>

eventhough having a file for all your javascript is probably better.

#4

drupalina - March 24, 2009 - 11:15

What exactly do you mean by an external js file? I have many js files from different modules, which are addregated by the JS Aggregator module. Are you saying I should have another separate JS file that I should put in the theme directory? Please elaborate.

Also: I've pasted your code at the top of my page.tpl.php , but I can't seem to fetch the CSS tags. I tried numerous combinations , but nothing works! What would be the correct line for a CSS???

the standard drigg CSS is
#content_center div.controlbar ul.drigg-viewtype
#content_center div.controlbar ul.drigg-viewtype li
#content_center div.controlbar ul.drigg-viewtype li.active a
#content_center div.controlbar ul.drigg-viewtype li a:hover
#content_center div.controlbar ul.drigg-viewtype li a.active:hover
and
#content_center div.controlbar ul.drigg-order
#content_center div.controlbar ul.drigg-order li a
#content_center div.controlbar ul.drigg-order li.active a
#content_center div.controlbar ul.drigg-order li a:hover
#content_center div.controlbar ul.drigg-order li a.active:hover

So what kind of lines should I put for the .upcoming ??

thanks!

#5

munikho - March 24, 2009 - 20:08

Well, I have an external js file to keep all my functions in there. But you don't need to, you can just keep it in the head of the page template.

the css would probably be:

#content.upcoming #content_center div.controlbar etc.....

hope this works.

#6

drupalina - March 25, 2009 - 12:04

Nope... nothing seems to work.

I tried the following tags
#content.upcoming #content_center div.controlbar ul.drigg-viewtype
#content.upcoming #content_center div.controlbar ul.drigg-viewtype li
#content.upcoming #content_center div.controlbar ul.drigg-viewtype li a
#content.upcoming #content_center div.controlbar ul.drigg-viewtype li.active a
#content.upcoming #content_center div.controlbar ul.drigg-viewtype li a:hover
#content.upcoming #content_center div.controlbar ul.drigg-viewtype li a.active:hover

#content.upcoming #content_center div.controlbar ul.drigg-order
#content.upcoming #content_center div.controlbar ul.drigg-order li a
#content.upcoming #content_center div.controlbar ul.drigg-order li.active a
#content.upcoming #content_center div.controlbar ul.drigg-order li a:hover
#content.upcoming #content_center div.controlbar ul.drigg-order li a.active:hover

... and it doesn't seem to catch anything ;(

any ideas?

#7

munikho - March 25, 2009 - 15:16

You are executing the jquery line before loading jquery. So put the line in the bottom of the head. Otherwise even on the bottom of the page.

#8

drupalina - March 25, 2009 - 16:08

Hi.. that's right... I now put the jquery code inside the < body > and it works ... almost.

BUT... I think this is a very bad way of doing this. Right now, the page loads and those Upcoming (and newsest, oldest, mostpopular, leastpopular) will first load under the usual colours of the Popular section, and once the page is fully loaded, only then will they change their colours to the colours of the Upcoming section. The whole effect just looks disorienting, and it looks like the site is "slow"!
In addition, there is no way to theme the "Upcoming" link differently when we are on the homepage. And when we are viewing the "Upcoming" section there is no way to theme the "Popular". Ultimately it would be cool if Popular was in Yellow (for example) and Upcoming in Grey on ALL pages.

Wouldn't it be much more efficient and effective if this was done through drigg_ui.module ???

My other concern is that I still can't theme the #header_categories and ul.drigg_categories when we are in the Upcoming section.

Thanks Munikho!

#9

munikho - March 25, 2009 - 17:31

I know, through the drigg_ui.module would probably be better, but since i've no idea how to do that right now, i think this is a suitable solution.
I'm surprised by the slowness of the jquery though, probably also because of all the other javascript on the page, it's loading last.

Theming the categories is possible, if you want to theme the header, attach the upcoming class one dom level higher. Like to #container.

$('.drigg-viewtype li:last.active').parents('#container').addClass('upcoming');

Maybe try checking in the module if you want to theme the popular and upcoming links on all pages.

Good luck.

#10

philbar - June 5, 2009 - 05:00
Category:support request» feature request
Assigned to:Anonymous» philbar

Will tackle this when I on the following:

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

#11

philbar - June 5, 2009 - 21:46

Where might I find file containing producing <li class="active"></li> and <ul class="drigg-order">?

I did a quick scan of drigg_ui.module and the default theme files using find and replace but came up empty handed.

#12

mercmobily - June 6, 2009 - 02:32

Hi,

The code that generates that is a *bit* complicated.

Quick idea: doesn't this issue have a simple template solution, by ust checking arg(0) to see if it's 'upcoming' and adding a div accordingly? This should be added to the page.tpl.php file around:

          print drigg_ui_sections(FALSE,0);

So that should be the solution to this problem, I assume?
Philbar, if my solution works, please mark this issue as fixed.

Merc.

 
 

Drupal is a registered trademark of Dries Buytaert.