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

Comments

BradM’s picture

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

BradM’s picture

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'] ?>.

mooffie’s picture

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.

mooffie’s picture

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.

chadchandler’s picture

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.

quicksketch’s picture

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.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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