I'm using a very involved custom profile template and would like to include the user-favorites list in it. How might I accomplish this?

Comments

dzynz’s picture

Sorry - I found this

<div id="favorites">
	<?php
	    $info = favorite_nodes_user($op = "view", $edit, $user);
	    foreach($info as $value){
	        foreach($value as $stuff){
	            foreach($stuff as $moreStuff){
	                if($moreStuff){
	                    print($moreStuff);
	                }               
	            }
	        }
	    }   
	?>
	</div>

But it really doesn't work the way it does on an un-templated profile. How can I get that functionality?

asund’s picture

Hi!
I had the same problem, but solved it by making a view with an argument for Added to favorite by ID and then just embedded the view in the profile using this code:

<?php
$view_name = 'profilefaves'; //name of view
$view_args = array($user->uid);
$view = views_get_view($view_name);
print views_build_view('embed', $view, $view_args, $view->use_pager, $view->nodes_per_page);
?>
neubreed’s picture

Here's another way to to do a teaser list in user_profile.tpl.php without needing to create a view

<?php $list = favorite_nodes_get($profile->uid, 'audio'); ?>
<?php if($list): ?>
    <?php print theme('favorite_nodes_view_teasers', $list, $profile->uid, 'Music'); ?>
<?php endif; ?>