Hello DOJO!

I want to be a Drupal ninja!

I have seen so many cool sites lately! There's one functionality set that has really caught my eye. I can't figure out how to do it, though. Can someone here give a hint? I've been through all the searches I can think of on Drupal.org and this is the first time I'm really asking, so I hope I give enough information! Here's a recent question verging on this: http://drupal.org/node/115058

What I'd like to do is display a view in a tab in a panel, and have the view be created by a stored argument that is autogenerated from the node ID.

The way this would be most useful is in something like the following:

A new content type is made for a group. Inside this content type is a query for the NID, which then populates this # into the views queries. The views queries are simple, like:

Lastest Posts
Latest Comments in the group
Latest '$CCK-Node-Type" posts in the group
Most Popular posts in the group

I think this would be a very slick way to do portals on a site in any fashion, and even better for groups that need to stay on top of things and get away from that default tabular format or the river of news.

Here are some beautiful Drupal site examples, so you can see this in action:

http://share.triangle.com/ the panels are "This just in" and "Things to do". Look at those beautiful tabs! Fast looking!!

http://teamsugar.com/ the panels are down in the footer-ish area, and show content from lots of places...great for easy access

http://www.newamerica.net/programs/new_america_in_california scroll down to see some really nice tabs that make finding things super easy on this content-dense site

In looking at the dynamicload module that comes with jstools, it seems like this is the kind of functionality I am after, and panels does handle views, and tabs are great and can be themed. I'm not so worried about the way this looks, but I am finding a big barrier with dynamicload in attempting to get a node loaded in the first place, much less injecting it into a panel, though I do understand now that panels do have a sort of ID system, and that addressing one in particular is very useful.

What are people using to do things like this? Tabs is easy, views is amazing, and panels seems like it's supremely useful for node layouts, but maybe panels isn't really necessary unless I want to put tab sets next to each other in different regions on the page?

Comments

discursives’s picture

have i asked for too many secrets? or is it just really hard to explain?

there must be a secret to it...I'll keep working on it! And report back!

DayShallCome’s picture

I'm also very interested in this.

discursives’s picture

i hear this is easier than i am making it seem...collecting the pieces now...seems this functionality is simply a view inside a tab.

discursives’s picture

Hello everyone, thanks for any help you can provide.

I was just reading this thread, http://drupal.org/node/98134#comment-187227, and Thom posted some code there, custom, where he inserted his views code along with layout information and a few other things into a single $output1 variable, then put that inside the tabs output. Can someone help me understand how to do this?

I'm at the same place in my work right now. I've got the Views configured and the tabs code here. Both work separately, but not together yet. Can someone please give me a hint?

Here's the code that Tom posted:

<div class=tabs150 style="margin-top:10px; ">
<?php
$output1 = '<div class=inner>';
$output1 .= _get_news();
$output1 .= '</div>';
$tab .= theme('tabs_tab_page', t('<B>News</B>'), $output1);
$output1 = '<div class=inner>';
$output1 .= _get_chatter();
$output1 .= '</div>';
$tab .= theme('tabs_tab_page', t('<B>Chatter</B>'), $output1);
$output = theme('tabs_tabset', 'home', $tab, 'grey_red_90');
echo $output;
?>
</div>

He created this custom function _get_chatter that obviously contains his view_get_view code. How does that happen?

Here's the views that I'd like to put into my own new function, something like _get_blogteasers()

 <?php
$view_name = 'teaserblog1'; //name of my first view which goes in the blog tab
$limit = 3; // number of returns
$view_args = array();
print views_build_view('embed', views_get_view($view_name), $view_args, FALSE, $limit);
?>

and my second view:

 <?php
$view_name = 'teaserstory1'; //name of my second view which goes in tab 2
$limit = 3; // number of returns
$view_args = array();
print views_build_view('embed', views_get_view($view_name), $view_args, FALSE, $limit);
?>

wants to be placed inside the tabs code:

<?php
  $tabs .= theme('tabs_tab_page', t('Blogs'), t('This is the place where I want the first view'));
  $tabs .= theme('tabs_tab_page', t('Stories'), t('This is the place where I want the second view'));
  $output = theme('tabs_tabset', 'example', $tabs);
  print $output;
?>

I notice in what you have above, Thom, that you are compressing the views code into a single variable, $output1. Can you show me how to do something similar?

discursives’s picture

Thanks to patrickharris who wrote a comment here: http://drupal.org/node/81798#comment-150204
$my-view-php-code-output = views_build_view('embed', views_get_view('name_of_my_view'), $view_args, true, $limit);
this allows me to define a variable containing my view code so I could write:

  $tabs .= theme('tabs_tab_page', t('My Tab Title'), t($my-view-php-code-output));
  $output = theme('tabs_tabset', 'example', $tabs);
  print $output; 

also, I shoudl say that I got an error until i added $view_args = array(); before the first views_build_view so put that at the top!

In the end, it looks something like this:

$view_args = array(); 
$my-view-php-code-output = views_build_view('embed', views_get_view('name_of_my_view'), $view_args, true, $limit);
$tabs .= theme('tabs_tab_page', t('My Tab Title'), t($my-view-php-code-output));
  $output = theme('tabs_tabset', 'example', $tabs);
  print $output;
shipal’s picture

Hi,

I'm a complete newbie to Drupal, and I would love to use something similar on my new site, could you post a step by step tutorial on this when you have time?

Thanks in advance !
Shirley
--
I'm from Hong Kong. My profile shows Thailand because Hong Kong was not available from the country list.

nevets’s picture

Using the t() function like this: t($my-view-php-code-output) where the value passed in is variable does not work as expected. The t() function only translates constant strings (with possible place holders). If the output of the view is possibly large your code will run faster without the use of the t() function in cases like this.

bsuttis’s picture

Tried the above code as a new node-page.tpl.php and tried inserting it as php code in a new content page, both returned this error:

Parse error: parse error, unexpected '=' in C:\www\xampp\htdocs\kidz\includes\common.inc(1342) : eval()'d code on line 4

Any ideas?

Running drupal 5.1 and the latest version of jstools.

djorn’s picture

PHP is trying to evaluate the $my-views... as an arithmetic operation. Change the - to _ and it should work.

DayShallCome’s picture

Check out this new post in the handbook:

http://drupal.org/node/124750

testerx’s picture

Attached is an image of what I did and would like to accomplish.

http://img230.imageshack.us/img230/9111/lookscu2.jpg

I'm fairly new to Drupal.. barely 2 weeks at most.. I would really like to know how to change the view when I click on the "Gallery" Primary Link.. instead of a vertical display of images and link.. I would like to put a Tab Navigation.. these Tab Navigation are sub-menus of the Primary Link "Gallery" .. basically they are image folders.. and they are defined in the Category as "terms or vocabulary" for "Image Gallery" Category..

I don't know about Php.... but I have a friend who does.. we help each other out.. i structure the website, and he promised to help with some Php coding if required..

from what I read here, I gather I need Views Module (already installed.. and practicing..), JSTools (installed), JQuery (do i have to install/add it ?!)

Using Views module, I stumbled upon the Theme Wizard... I created a view using the View Module and use it to generate Theme codes that I supposedly need to modify or add.. (ie template.php , the tpl file, and the css file..).. am I on the right track ?! Please help.

Now, my problem is where to start.. if somebody could help me out.. I would really appreciate it.

Thanks and more power.

catch’s picture

I'm not sure exactly what you're after, but there's a new (i.e. this week) tabbed panels blocks/panels in panels module that ought to work for that. Don't have the name handy though but it's something like panels blocks.

discursives’s picture

I am so grateful to nedjo and Funny Garbage and CivicSpace for this. Hooray!

mrgoltra’s picture

subscribing

totalsense’s picture

thanks for the info.