How can I put Popular and Upcoming links in ALL pages?

drupalina - March 13, 2009 - 08:59
Project:Drigg
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi,

Right now the "Popular" and "Upcoming" links appear only in a list view of scoops. When you are viewing a full node (for example posting a comment) those Popular/Upcoming links disappear. This makes user-navigation very disruptive and disorientating, and my esers keep complaining.

For example when I'm on Digg.com, those Popular/Upcoming links are always being displayed and I click them very frequently while digging latest posts.

In page.tpl.php we see that this navigation is controlled by

  <?php
           
if ($page == 0 && module_exists('drigg')) {
          print
drigg_ui_type_menu();
              print
drigg_ui_order_menu();
            }
         
?>

The key, it seems is the bit that says $page == 0 . It's basically saying "If the page is a list view"

What I want is for print drigg_ui_type_menu(); [this is the bit that prints Popular and Upcoming links] to display on ALL pages including the full-node pages, and print drigg_ui_order_menu(); [top24h, 7days, 30days, 365days] to display only on List views as it does already.

I've been trying to figure this out for many weeks now, so if any kind soul would help, that'd be much appreciated!!!

#1

munikho - March 18, 2009 - 02:21

Actually i'm wondering the same in version 6.x.

Noticed that the module decides if it should display 'published/upcoming' depending if it is in the url (and catching the exceptions before, like the homepage).
So when you view a node, there is no 'published' or 'upcoming' in the link, but only /node/33, so there is no menu.

It's not showing the category that was selected anymore either.

Anybody has any bright idea's on how to go around this?

#2

drupalina - March 18, 2009 - 19:17

I had a look at the drigg_ui.module and it seems like it has some part in this form of display as well.

Please someone have a look at this issue because my statistics on Google Analytics indicate that these Popular/Upcoming links are a main navigation links of the entire site. I guess this is the case for any Digg/Reddit site. Once people view the full node, they want to get back to finding new scoops in the Upcoming section, so what do they do??? There is no Upcoming or Popular link!

I've created 2 links in the primary menu that show Popular and Upcoming. But this is NOT a solution because it does not make drigg_ui_order_menu dependent on these links. This way if you are in Popular>>Top7days the "Popular" link will NOT remain active, while the drigg_ui_type_menu version of Popular/Upcoming do, which is very disorienting. Plus, it also means displaying Popular/Upcoming links twice on the same page, which is ugly, unprofessional and disorienting.

Please someone help...

#3

munikho - March 19, 2009 - 11:45
Status:active» needs review

Wow, i supprised myself here by actually making this work...

Maybe somebody can take a look, because it's very possible i'm doing something very 'illegal'.

I'll post my code here, since I don't know how to make a patch and anyway my drigg module is a little bit personalized.

In drigg.ui.module:

function drigg_ui_type_menu($promote) {
  $output = '';
  $selected_string = ' class="active" ';

  $p0 = arg(0);
  $p1 = arg(1);
  $p2 = arg(2);

  if (arg(0) == 'node' && $promote == '0' ) {
    $p0 = 'upcoming';
  }
  if (arg(0) == 'node' && $promote == '1' ) {
    $p0 = 'published';
  }

// etc etc

and in your page.tpl.php

// instead of

print drigg_ui_type_menu();

// do

print drigg_ui_type_menu($node->promote);

I'm using version 6 here, but i think this will work for 5 as well.

Maybe something like this could be included in the module? Depending on the theme, this could be a nice feature.

Tell me if it's any good though.

#4

drupalina - March 19, 2009 - 14:02

Hi,

I've tested your code on my 5.x live site. It works, but not fully!

For example, I have views where users see their Favourites, or Scoops posted by friends (I've done these using Views module), or pages where they look at the community (/profile) or Private messages, or OG groups etc etc. There are many pages, where these Popular/Upcoming links are still not displaying. Strangely enough, the Popular/Upcoming links are displaying on some other pages like static Page content types. I need them to display on ALL pages, like we see on Digg.com or Reddit, because these are the principal navigation links.

But at least this is a good start. What I also like about your code is the fact that when we are viewing a full node of an upcoming scoop, the Upcoming link above remains selected, which is another good reminder that we are still in the upcoming section.

I suspect the problematic aspect is either arg(0) == 'node' or promote == "o" in

  if (arg(0) == 'node' && $promote == '0' ) {
    $p0 = 'upcoming';
  }
  if (arg(0) == 'node' && $promote == '1' ) {
    $p0 = 'published';
  }

If you post a code that will display the Popular and Upcoming links on ALL pages of the site, I'll be willing to test it on my live site and report back to you.

PS: BZW, in 5x drigg_ui.module it read function drigg_ui_type_menu() not function drigg_ui_type_menu($promote) . Is there anything that I should be worried about?

#5

munikho - March 19, 2009 - 16:09

Well, right now the code is simply checking if the page you're viewing is a node and will then display the menu. You could just take away

arg(0) == 'node' &&

in the two if statementens and i think it would display on every page. But in this case the upcoming menu item will be selected. Which is also the case now when you view a page. So that's not really correct yet.

Btw, about the last thing. You need to change

function drigg_ui_type_menu()

into

function drigg_ui_type_menu($promote)

Hope this helps a bit, what's your live site anyway?

#6

munikho - March 19, 2009 - 16:50

Ok, i think i have it.

in the theme:

print drigg_ui_type_menu($node->promote, $node->type);

in drigg_ui.module

function drigg_ui_type_menu($promote, $type) {
  $output = '';
  $selected_string = ' class="active" ';

  $p0 = arg(0);
  $p1 = arg(1);
  $p2 = arg(2);

// added by munikho, makes sure menu is also on the nodeview
  if ($promote == '0' && $type == 'drigg') {
    $p0 = 'upcoming';
  }
  if ($promote == '1' && $type == 'drigg') {
    $p0 = 'published';
  }
  if (arg(0) == 'node' && $type != 'drigg'){
    $selected_string = '';
  }

and then comment out

  // This avoids doing anything if the URL is incorrect
//  if ($p0 != 'published' && $p0 != 'upcoming' && $p0 != 'archived') {
//    return '';
//  }

I hope that with this it all works.

#7

drupalina - March 19, 2009 - 17:07

I've tested your code from #6. So far so good. Everything seems to work! No php errors in the watchdog log.

Will report if I find any errors.

Thanks!!!

I'll e-mail you directly about my site ;)

#8

drupalina - March 19, 2009 - 18:34

BZW, here's a related question, which I'm sure many other Driggers would love:
do you 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 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.

Any ideas?

#9

munikho - March 19, 2009 - 23:37

Happy that it works for you.

The other question, i guess the easiest way i can think of now, is to just do it with a little bit of jquery and css.
Detect with jquery which tab is selected and add a class to the parent div.

#10

drupalina - March 20, 2009 - 08:50
Status:needs review» fixed

I'll close this issue, since it's sorted (if any bugs crop up, please reopen it).

As for the question in the other issue, I'll open a new issue - that's the right way.

Thanks again.

#11

munikho - March 20, 2009 - 15:02
Status:fixed» patch (to be ported)

Would be great if this could somehow be merged in version 5 and 6, maybe there could be an option made in the backend where you can select if the menu should always be visible. I'm not sure how to do that.
I'll add the patch here.

For this to work, the theme also has to be changed a little bit.
from this:

print drigg_ui_type_menu();

to
print drigg_ui_type_menu($node->promote, $node->type);

#edit
Patch is for 6dev

AttachmentSize
type_menu.patch 1.38 KB

#12

drupalina - July 2, 2009 - 19:47
Category:support request» feature request

Hi Merc, (I hope you're reading this)

After listening to most of feedback from my end users, I'd say, it would be _essential_ and _crucial_ that something like this be adopted as a standard in future releases of Drigg (both in 5x and 6x).
Popular and Upcoming links should _REALLY_ appear on ALL pages, just like we see on Digg.com and many other such social news sites.

#13

mercmobily - July 7, 2009 - 19:58

Hi,

Drupal, about #8, please keep threads on topic in line.
Now... I think you are right in principle, and I am happy to apply this even tough I am focussing on bug fixes only.

However... can somebody post a *final* *working* and at least half-tested solution? I am not entirely sure *which* bit from each part I should take...

Bye,

Merc.

#14

drupalina - July 8, 2009 - 02:58

Hi,
I have this solution up and running on my live site since about March 20. Check it out. It works!, but not fully. There are some (very rare pages) whereby if you click one of those Popular/Upcoming links, it will bring you to "Page not found".
For example, if you are on /vocabulary/2 and you click on "Upcoming", it will bring you to "Page not found" because the URL that it is looking for is /upcoming/newest/2. Or if you are on /taxonomy/term/1343 and you click on "Popular" it will bring you to "Page not found" because the URL shows /published/newest/1343.
Or if I'm on /search/node/foofoo and then click on "Upcoming", it will try to look for /upcoming/newest/foofoo
Other than these occasions, I think this solution generally works.

I haven't applied the patch in #11 - simply because I still don't know how to apply patches. If I remember correctly, I just fiddled around with the drigg_ui.module with the code-replacements provided by Munikho above (like in #6 and #11), and it started to work.

Do you want me to attach my drigg_ui.module file?

#15

munikho - July 8, 2009 - 10:01

I will provide a new patch soon.

I just need to dive back into the code (long time ago).

#16

mercmobily - July 8, 2009 - 16:08

Hi,

OK thank you!
Once you submit it, I will integrate it into Drigg. That way you won't have to maintain a fork...

Merc.

#17

munikho - July 8, 2009 - 22:10
Version:5.x-1.36» 6.x-1.x-dev
Status:patch (to be ported)» needs review

I resubmit the patch here.

This does need to be tested, because it's probably not perfect yet.

As mentioned above. The theme (page.tpl.php) needs to also be changed a bit. From:

print drigg_ui_type_menu();

to:

print drigg_ui_type_menu($node->promote, $node->type);

hope it works.

m

AttachmentSize
menu_always_visible.patch 1.58 KB

#18

mercmobily - July 22, 2009 - 18:24

Hi,

Can others here please test this patch?

Merc.

#19

feconroses - July 25, 2009 - 00:27

I have tried it. The popular and upcoming links appears on every page, but i get this error:

warning: Missing argument 1 for drigg_ui_type_menu(), called in /home/gentpas1/public_html/themes/drigg_theme/page.tpl.php on line 101 and defined in /home/gentpas1/public_html/modules/drigg/drigg_ui/drigg_ui.module on line 931.
warning: Missing argument 2 for drigg_ui_type_menu(), called in /home/gentpas1/public_html/themes/drigg_theme/page.tpl.php on line 101 and defined in /home/gentpas1/public_html/modules/drigg/drigg_ui/drigg_ui.module on line 931.

Maybe its just me, i apply patches manually but i never had a problem with that.

#20

feconroses - July 25, 2009 - 00:29

I forgot to mention that i also made the suggested change in page.tpl.php

 
 

Drupal is a registered trademark of Dries Buytaert.