snippets to be used in custom user profile

anakcerdas - May 1, 2008 - 10:18
Project:Views Bookmark
Version:5.x-1.4
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello,

I'm using custom user profile template as was mentioned at http://shellmultimedia.com/tutorials/user-profiles-version-2. Is there a PHP snippet to put a "Bookmark this" in the template?

Thank you for the help.

Regards,

PITRA

#1

BradM - May 1, 2008 - 22:37

I discovered it's a pretty easy thing to do. What I've done seems to work. ;-)

Edit your node-uprofile.tpl.php file, found in your theme directory. Around line 221 you'll see <!-- LEFT PANEL -->. Essentially I duplicated the code for the user tracker from this section, and added it below.

So replace this code:

<!-- LEFT PANEL -->
  <div class="panel-col-first">
    <div id="user-tracker">
      <h3>Topics I've participated in:</h3>
      <?php
      $view
= views_get_view('user_tracker');
      print
views_build_view('embed', $view, array(strval($profileuser->uid)), 1, 15);
     
?>

    </div>
  </div>

  <!-- RIGHT PANEL -->

With this code:

<!-- LEFT PANEL -->
  <div class="panel-col-first">
    <div id="user-tracker">
      <h3>Topics I've participated in:</h3>
      <?php
      $view
= views_get_view('user_tracker');
      print
views_build_view('embed', $view, array(strval($profileuser->uid)), 1, 15);
     
?>

    </div>
    <div id="user-tracker">
      <h3>My bookmarks:</h3>
      <?php
          $view
= views_get_view('bookmarks_1');
          print
views_build_view('embed', $view, array(strval($profileuser->uid)), 1, 15);
         
?>

    </div>
  </div>

  <!-- RIGHT PANEL -->

It uses the existing view created by this module. My view is called "bookmarks_1" (with the URL bookmarks/1 for some reason...) but yours should be similar. Basically what I've done is place the bookmark list below the user tracker, but I'm sure you could place it elsewhere on the page.

Note that there's no way for a user to turn off the display of their bookmarks; it's all new to my website, so I've yet to discover if any members would prefer that their bookmarks not show up in their profile...hmm I suppose you could make a profile field to allow/disallow this, then check for it in the template...not sure.

Brad

#2

BradM - May 1, 2008 - 23:05

Forget the above post, it doesn't work. It actually results in showing my bookmarks within their profile... as in, if I visit john's profile page, my bookmarks will show there, rather than his. No idea why. :(

And, I just realized I didn't actually answer your question. I see in CCK there is a field called $node->links['links_bookmark_1'] (array) with a few parts to it, maybe this will get you started. I use Jrating for rating nodes, and simply add <?php print $node->jrating_html ?> to my template for the rating stuff. Maybe there's something similar embedded as part of this module, like <?php print $node->links['links_bookmark_1'] ?>.

#3

mooffie - May 2, 2008 - 01:27

Is there a PHP snippet to put a "Bookmark this" in the template?

You can bookmark only nodes.

You can construct a link that bookmarks a profile node, but it will still bookmark a node and won't lead to the user page (q=user/123). That's not what you want.

OTOH, if you're using the 'bio' module, then it has an option to redirect to q=user/123 when the 'biography node' is viewed. So in this case the link that bookmarks this node will do what you expect.

#4

mooffie - May 2, 2008 - 01:36

My view is called "bookmarks_1" (with the URL bookmarks/1 for some reason...)

The '1' stands for the bookmark id (e.g. 'Favorite posts'). It isn't the user id.

Forget the above post, it doesn't work. It actually results in showing my bookmarks

That's right. This view has a filter that restricts the nodes to those bookmarked by the 'current user'. You can modify the view: remove that filter and instead add a 'bookmarking user id' argument.

#5

Prodigy - May 29, 2008 - 02:36

If you want to show bookmarks in the user profile , and your using the newest "advanced profile" module it's really easy to do.

Just create the view, details on the view to show the bookmarks can be found around here somewhere, and import it into the user profile view using panels.

#6

quicksketch - June 12, 2008 - 05:00
Status:active» fixed

Let's mark this fixed since we haven't heard from the author since he posted.

Also, keep tabs on #233172: Provide an API function, for use by themers, to print a mark/unmark link which may also help the situation.

#7

Anonymous (not verified) - June 26, 2008 - 05:03
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.