There already exists a nice way to append the status form (textfield, submit button, etc.) to a view (see for example http://drupal.org/node/479306), so that both are displayed together and the view is automatically updated using AHAH. All you have to do is create a node or block, and put a simple php call in it that passes in the view's machine-name to the theme function, like "facebook_status_ur" in this example:

theme('facebook_status_form_display', $user, 190,'facebook_status_ur', FALSE );

This is great, but the current code only works for the default-display of the view. Sometimes, a view can have many displays, and I'd like to be able to apply the input-form to a non-default display (or maybe even several).

It is a very simple fix, and I appended it in the attached file:

In facebook_status.module, the theme function just needs an extra argument for the desired display name: $display_id

function theme_facebook_status_form_display($account = FALSE, $size = FALSE, $view = FALSE, $view_arg = FALSE, $display_id = 'default') {
  ...
  if ($view && module_exists('views')) {
  .... // change this in both places where "view_embed_view" is called
      $rendered_view = views_embed_view($view, $display_id, $arg, $arg2);

The extra argument is also registered in hook_theme.

You then call the function like this, with an optional machine-name of the display.

theme('facebook_status_form_display', $user, 190, 'facebook_status_ur' );
OR
theme('facebook_status_form_display', $user, 190, 'facebook_status_ur', FALSE, 'book_5' );

BTW, the way to find the machine name of the display is go the the view's edit page, and simply hover the mouse over any of the view's links. It will display a URL, which includes the view's name and the display.

Alternatively, if you don't want to change the function signature, you could overload the 'view' argument to either be a single string (as it is now) OR an array that holds both the view name and the display. But I think the above change is simpler.

Right now, I simply put the fix into my theme's template.php file, but I think it would be generally useful, and should become part of the main-module. I attached the solution in a file.

CommentFileSizeAuthor
theme_facebook_status_form_display.txt2.42 KBhoporr

Comments

icecreamyou’s picture

Version: 6.x-2.3 » 6.x-2.x-dev
Issue tags: +FBSS3

I'm not making any changes to the 2.x branch, API or otherwise, except for critical bug fixes. Since the 3.x code is in CVS but not tagged for release yet, I'm just adding a tag to this post ("FBSS3") to indicate that this is really a 3.x issue.

In the 3.x branch, this is significantly more complicated. The API allows specifying a default view for various contexts ("contexts" being a new idea introduced in 3.x) that users can then change via the interface. So any change that allowed selecting non-default displays would also have to add this ability to the UI.

icecreamyou’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
sansui’s picture

This was a pretty big help hoporr - I was investigating this myself after creating a facebook style news feed with user relationships, and was staring at the theme function when I decided to see if anyone else had already figured this out - lo' and behold a perfect and simple explanation :)

Thanks a bunch!

salientknight’s picture

First off... I love this module. Thanks Ice. That said, I am having a real issue. I have a long user profile and I really need the wall to be something separate from the profile. I've explored hacks, even going so far as to move the profile information to another page (which of course resulted in all views user links going to the wall not the profile) and I have looked all over good and this site for a solution that works. So I ask. Is there a way to get the Status update form on another page? Code, a link, a module... anything would be greatly appreciated. I'm willing to go to version 3 if that will help me pull this off, but it does not sound like 3 does this either.

I have 6.x-2 and also use Micropublisher

Thank you.

sansui’s picture

salient, you can absolutely do this :) The easiest way for me was to create a new page callback in my custom site function that adds a tab to the user account area

  $items['user/%user/newsfeed'] = array(
    'title' => t('News Feed'),
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'mymodule_profile_news_feed',
    'page arguments' => array(1),
  );  
function mymodule_profile_news_feed($arg) {
	$output = '<div class="profile">';
	$output .= '<div class="news-wall">';
	$output .= theme('facebook_status_form_display', $arg, 190,'facebook_status_stream', FALSE, 'block_2');
	$output .='</div>';
	$output .='<div class="social-sidebar">';
	$block = module_invoke('ud', 'block', 'view', 'ud-user-block');
	$output .= $block['content'];
	$output .= '</div>';	
	$output .= '</div>';
	return $output;
}

You'll notice that my use of facebook_status_form_display is a bit different since I customized my theme function to include argument for a different view to use (in my case, facebook_status_stream), so you could just use theme('facebook_status_form_display',$arg) I think and get the form you want on your brand new page. I'm a bit pinched for time at the moment but try googling that function or check it out in the module files - there may even be an existing block you could just plug in using something like user displays.

salientknight’s picture

I'll give this a try. Thank you very much!

salientknight’s picture

Hey Sansui,

This is creating an alt link to my profile page. Not a wall page with a Status Form on it. When I change my profile template, it changes this page.

But this did give a good work around. Having created the new link I added the follow code to my user-profile.tpl.php:

//checks the current path against the newsfeed path and displays the facebook status only on the newsfeed path.
//*NOTE uses me module to resolve %user

<?php if(drupal_get_path_alias($_GET['q'])=="user/me/newsfeed"): ?> 
         <div class="userStatus">
			<?php print $profile ['facebook_status'];?>
	</div>
<?php endif; ?>

Thank you very much!

sansui’s picture

Are you using hoporr's theme modifications above?

In any case, you can even try this on a normal page, with the PHP input filter, if something this simple is all you need.

global $user; print theme('facebook_status_form_display', $user, 190, 'facebook_status_ur' );

This will display the status update form + the default wall for the current user. If you want to use it as a module, which I recommend, you can change the menu item to be a normal menu item instead of a local task, and give it a normal path like "mywall" instead of "user/%user/newsfeed"

You'll need to remove the page argument and user the $user object instead

salientknight’s picture

Thanks again. This worked great as a header on the views. My first attempt was to use it in a block which did not work. Problem is solved now though. Thanks much!.

icecreamyou’s picture

Status: Active » Fixed

I just committed an API change to dev that adds a $display parameter to theme('facebook_status_form_display') so that this would be possible. I'm not going to expose it via a UI, however, because it's just too difficult to figure out how to make sure that users can't select a display that is not valid for the selected view. (If someone else wants to write a patch that provides such a UI, I'm open to reviewing it.)

FrankzeTank’s picture

Version: 6.x-3.x-dev » 6.x-3.0-rc2

I'm a bit confused, was there any fix or option for 6.3.0-rc2 as I'm using that and all I want to do is change the page that the wall is is essentially on as explained above? I tried the above solutions with no help. After reading the documentation it seems that for 6.3x the function is

theme('facebook_status_form_display', $context = NULL, $type = NULL, $view = NULL, $display = 'default')

I don't understand how to implement the appropriate $context as explained in the documentation. I played around with facebook_status_determine_context(), and facebook_status_all_contexts(). But there isn't any specific context to the user page i'm on via the user object or something else it seems.

Right now I have a basic hook_menu:

function sarcacore_menu(){
//Adds a page for the walls.
	$items = array();
	$items['profile/%user_uid_optional/wall']= array(
	'title' =>'Wall',
	'page callback' => 'wall_render',
	'page arguments' => array(1),
	'access arguments' => array(1),
	'access callback' => 'wall_access',
	'file'=> 'wall.pages.inc',

	);
	return $items;
}

The only thing appended above is the user argument and wall argument was added to the end. And all I want is to render the wall on this page for every specific uid in arg(1), so all users have a consistent wall page @www.example.com/profile/[uid]/wall.

My 3 other functions are

function sarcacore_theme($existing, $type, $theme, $path){
	return array(
		'wall' => array(
		'arguments'=> array('wall_id'=> NULL),
		'template'=>'wall',
		
		),
	);
}

//Renders the wall for wall pages
function wall_render($user){
	$wall_id = $user->uid;
	$output = theme('wall',$wall_id);
	return $output;
}

function template_preprocess_wall(&$vars){
$vars['wall_form']= theme('facebook_status_form_display', $context = NULL, $type = NULL, $view = NULL, $display = 'default');
	
}

-Wall Template prints the $wall_form

It will print the wall form for the user on the page but it also does it for all the profile pages rather than just their's. I think I understand how the theme() function works for 2.x but I don't understand the context system at all I'm afraid. I hate asking for help, but I've already spent all day 6+ hours trying to figure this out. Any and all help is much appreciated, thanks a lot.

icecreamyou’s picture

@FrankzeTank: Your question is unrelated to this thread -- it would be much better in its own issue -- but you will need to create a View that takes a Recipient ID argument from the URL and then either make that the default view for user streams at admin/settings/facebook_status/contexts or pass it in to your call to theme('facebook_status_form_display') in your code.

Michael3185’s picture

Issue tags: +wall, +status form

Edit: Can be deleted. Don't code tired... :)

liliplanet’s picture

subscribe, thx! would love to know how to append a status box on any view :)

icecreamyou’s picture

You can already append any view to the status update box. This issue is about using non-default displays on the appended view, and it is fixed.

Status: Fixed » Closed (fixed)
Issue tags: -FBSS3, -wall, -status form

Automatically closed -- issue fixed for 2 weeks with no activity.