I'm having an issue trying to insert a view within QT manually. For inserting a view I gather you use something like...

$tabs[0] = array(
  'title' => t('Articles'),
  'type' => 'view',
  'vid' => 'Articles',
  'display' => 'block_2',
  'args' => arg(1),
);

This works fine with pretty much all views however I'm using a code snippet associated with the facebook style status module which allows a user to post a status and in doing so the view is automatically updated. Here's the code I used for this...

$account_notebook = user_load(array('uid' => arg(1)));
$notebook_size = variable_get('facebook_status_size_long', 40);
$notebook_view = 'notebook';
$notebook = theme('facebook_status_form_display', $account = $account_notebook, $notebook_size, $view = $notebook_view);
print $notebook;

I previously was using the magic tabs module and was able to use this without any issues. However it does seem as if the module is slowly dying out and has a few views related bugs.

So I guess my question is about how to use this code with QT because QT's seems as if you need to define a type of content in order to render it. In my situation although the content is coming from a view there is also a few lines of PHP needed to display the FBSS form. I don't see why this can't be done but I assume it's not a simple point A to B method.

I'm thinking I'll have to do this as a block type? Is that my only option? And if so could I just print out $block->content instead of using bid in an array?

Thanks,

Walker (Go Bills!)

Comments

pasqualle’s picture

#332895: render quicktab programatically

...
$tabs[0] = array(
  'title' => t('Facebook status'),
  'type' => 'freetext',
  'text' => $notebook,
);

...
$quicktabs['ajax'] = FALSE;
...
walker2238’s picture

Ah, I also should have mention that I need ajax calls. So freetext is not an option, sorry. I did put the code in a block but it seems as though the views argument doesn't take effect.

pasqualle’s picture

you are right, there is no other option to use php snippet as tab content..

I don't know which module you use to display the facebook status, so I don't see what could be wrong with the view argument. Both code snippets seems good generally..

walker2238’s picture

The module is called facebook-style-status. The view argument is fine it's when I put that code within a block and called that block with QT's. Theres no argument for embedding blocks.

Is there a reason why freetext can't be used with ajax mode?

pasqualle’s picture

I am not sure if I understand you correctly.

The view argument is fine it's when I put that code within a block and called that block with QT's.

ok, so what's the problem, what else do you need?

Theres no argument for embedding blocks.

This sentence is meaningless, I don't know what you are trying to say with that.. Do you want to pass user id to block?

You are using arg(1) as user id, so if you display the quicktab on the user page, then that code should work..

freetext type don't work in ajax mode, because QT don't store (just displays) the string from the 'text' field. It needs to be stored somewhere (or needs a function which could return that text) to load content dynamically.

walker2238’s picture

Sorry about that,

Basically whats going on is I created a view, but the view I created needs the following...

$account_notebook = user_load(array('uid' => arg(1)));
$notebook_size = variable_get('facebook_status_size_long', 40);
$notebook_view = 'notebook';
$notebook = theme('facebook_status_form_display', $account = $account_notebook, $notebook_size, $view = $notebook_view);
print $notebook;

The reason because is that when the form is submitted the text of the form will get placed in the view via ajax, without a page refresh.

Since I require this code to be used, I cannot user 'type' => 'view' because of the included code.

As a result I thought an ideal solution would to put that code within a block and call the block with QT. However since I can't use an argument in the array the view returns empty.

And as you sugested, freetext isn't an option because the amount of content I have within each QT. Thus using ajax calls seem the most appropriate.

And I am using arg(1) as user id my argument in my views along with QT arguments for the views, but that isn't a problem. The main issue is using an argument for embedding a block because of the code i'm using contains a view.

pasqualle’s picture

my first reaction: what? I have absolutely no idea what are you talking about.. It's like Chinese to me..

now I try to guess what are you trying to do: You have some kind of facebook status form. When the form is submitted the result should be displayed in your custom view. Is that what you want?

So, my simple question: can you do that without the QT module? If not, then probably QT will not help you. QT just displays content, it does not provide any magic functionality..

walker2238’s picture

Ha, okay I'll try once more.

I have the form and view combined with the code I posted above. That's not the issue. The issue is how to get that code within a quick tab. I previously was using magic tabs, and the funny thing was that embedding it within magic tabs was the only thing that worked (Module have a lot of bugs and seems to have no support). I was able to do this like so...

  $tabs = array(
    array('title' => t('Articles')),
    array('title' => t('Notebook')),
    array('title' => t('Inside Scoop')),
    array('title' => t('Recommendations')),
	array('title' => t('Subscriptions')),
    array('title' => t('Subscribers')),
  );
  $active = ($active + 6) % 6; // $active could be -1, which means last (set number to amount of tabs used.)
  $ordinals = array($articles['content'], $notebook, $subscription_feed['content'], $recommendations['content'], $subscriptions['content'], $subscribers['content']);
  $tabs[$active]['content'] = $ordinals[$active];
  return $tabs;

QT has a different structure so I'm trying to figure out a logical way to accomplish the same task.

As mention earlier I wish not to use freetext because I need ajax. Using view type is also not an option because of the php code. If I used a view type the form wouldn't be printed thus removing the ajax updates for the facebook style form and view.

So I tried to use type block but the problem with that was my view returns empty. I assume the reason being is I can't use an argument the way you are allowed to when using a view type.

Sorry if you still don't understand.

Thanks, Walker

pasqualle’s picture

can you post a working freetext solution. That would help me to understand, and I can help you change it to ajax mode with using a block.

walker2238’s picture

Thanks so much for your help Pasqualle.

Basically what you post in your first reply was what I had for freetext.

$account_notebook = user_load(array('uid' => arg(1)));
$notebook_size = variable_get('facebook_status_size_long', 40);
$notebook_view = 'notebook';
$notebook = theme('facebook_status_form_display', $account = $account_notebook, $notebook_size, $view = $notebook_view);
print $notebook;

$tabs[0] = array(
  'title' => t('Notebook'),
  'type' => 'freetext',
  'text' => $notebook,
);

...

$quicktabs['qtid'] = '1';
$quicktabs['tabs'] = $tabs;
$quicktabs['style'] = 'Default';
$quicktabs['ajax'] = TRUE;
print theme('quicktabs', $quicktabs);

Obviously I have a few other tabs but didn't see a need to include them as they all work for the most part. (There is a issue regarding using variables within a view, such as $account->uid in a header or for a empty view but thats for another issue.)

pasqualle’s picture

ok, if you put the code into custom php block and use

$tabs[0] = array(
  'title' => t('Notebook'),
  'type' => 'block',
  'bid' => 'block_delta_3', // use your block delta here
  'hide_title' => TRUE,
);

then it should work same as freetext

but the problem is that the block with your code don't work in ajax mode, as arg(1) will not return the user id, because in ajax mode the block will be loaded dynamically on path "quicktabs/ajax/block" so arg(1) == 'ajax'

I think there is no clean solution for this code in ajax mode quicktab..

ltwinner’s picture

...nvm

nicostabile’s picture

Sorry about i open this topic, but I have been doings many attepmts and I can´t realize how to do this:

i ´m starting with drupal, and i ´m trying to do a tab menu for all dinamics groups. I try to do a menu tab that each tab is one organic group, these groups are created dinamically, so when a user create a group i want that in menu tabs appears automatically a new tab for this group.
I want to do that because i want to organize in tabs all the content of each group.
Really i don´t know if is it possible to do, Someone knows if is it possible?, if anyone can give me an idea to begin to learn, i would be very grateful.

I ´m working with Drupal 6.17,Organics Groups 6.x-2.1,Organic groups Views integration 6.x-2.1 and views 6.x-2.11.

this post is at: http://drupal.org/node/844806

i want to know if is possible to do this with quick tabs.

thanks you very much for all.

Nicolás.

netw3rker’s picture

Status: Active » Closed (fixed)