1

I'd like to display the # (count) of Blogs on my quick tab menu. Ex: Blogs (3)

I found a way to overwrite the quicktab titles using the following function with an if statement

   function mymodule_quicktabs_alter($quicktabs) { 
if ($quicktabs->machine_name == 'quick_tab_front_page') { 
$quicktabs->tabs = array(
  0 => array(
    'machine_name' => 'quick_tab_blogs',
    'title' => 'BLOGS',
    'weight' => '-100',
    'type' => 'qtabs',
  ),
  1 => array(
    'machine_name' => 'quick_tab_news',
    'title' => 'NEWS',
    'weight' => '-89',
    'type' => 'qtabs',
  ),
);
$quicktabs->renderer = 'quicktabs';
$quicktabs->style = 'Arrows';
$quicktabs->options = array();
}
}

I created a view, using the Views module, which contains all the blog titles written by a user.

Now I need to figure-out a way to display the views' count on the quick tab title

I have tried

function mymodule_quicktabs_alter($quicktabs) { 
    $view = views_get_view('user_blogs');
    $view->set_arguments(array($account->uid));
    $view->execute(); 
    $count = count($view->result);
if ($quicktabs->machine_name == 'quick_tab_front_page') { 
$quicktabs->tabs = array(
  0 => array(
    'machine_name' => 'quick_tab_blogs',
    'title' => t('Blogs @count', array('@count' => $count));

but it gives me an error of Fatal error: Call to a member function execute() on a non-object for the line $view = views_get_view('user_blogs');

I don't get why, I am new to php.

  • 1
    It is working fine for me. Check your view name that you are passing to views_get_view() and also from where are you getting the $account variable from. – wolverine Jun 13 '14 at 6:14
  • 1
    Yeah the view is not loading okay, so it's probably just the view name in views_get_view(). – Bryan Jiencke Jun 13 '14 at 13:34
  • yeah it was the view name, rookie mistake. I also got rid off $view->set_arguments(array($account->uid)); turns out I don't need it. – No Sssweat Jun 13 '14 at 13:59
1

Check your view name that you are passing to views_get_view() and also from where are you getting the $account variable from (credits: wolverine).

And get rid off $view->set_arguments(array($account->uid));, you don't need it (credits: No Sssweat).

  • Brings back Drupal newbie memories. – No Sssweat Jul 15 '16 at 8:08
  • From Drupal 4.6 or 5? The question doesn't make that clear ... yet ... Maybe it needs an updated answer for D8 also ... – Pierre.Vriens Jul 15 '16 at 8:14
  • 1
    From Drupal 4.6 or 5? hahaha, I can't imagine what those versions looked like. BTW I've been using Drupal since I joined this site. – No Sssweat Jul 15 '16 at 8:47
  • OK, now this question may become a candidate for some meta-question around there to get a D8-equivalent answer ... unless of course you post your own answer like yourself ... or maybe Quick Tabs are gone in D8 (haven't checked yet) ... – Pierre.Vriens Jul 15 '16 at 8:52
  • 1
    No quicktabs for D8 yet. The ajax in quick tabs doesn't load js files from the node/block/view. Now days, I use my own custom/superior quicktabs. – No Sssweat Jul 15 '16 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.