Gossamer Forum
Quote Reply
function isBookmarked?
Hi,

i am searching for a function, that can check inside the link.html, if the link is bookmarked or not.
So i want to fadeout the bookmark-link then. ;-)

Greetings
Coyu
Quote Reply
Re: [Coyu] function isBookmarked? In reply to
Hi,

This will work (just tested it). Make a new global called "check_bookmarked", with the following code:

Code:
sub {

my $count = $DB->table('Bookmark_Links')->count( { my_link_id_fk => $_[0], my_user_username_fk => $USER->{Username} } ) || 0;

$count ? return { isBookmarked => 1 } : return { isBookmarked => 0 }

}

The, in link.html add:

Code:
<%check_bookmarked($ID)%>

at the top of the template.

Then, you can use:

Code:
<%if isBookmarked%>alreadybookmarked<%else%>show bookmark link<%endif%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Jan 20, 2008, 11:45 PM
Quote Reply
Re: [Andy] function isBookmarked? In reply to
Thanks but for me it shows "show bookmark link" for ALL links.
Quote Reply
Re: [socrates] function isBookmarked? In reply to
Hi,

Mmm.. you sure? Where are you placing this template code? Which version of GLinks? I've tested it on 3.0.4 and 3.2.0, and works fine.

Only thing I can think of - is maybe trying:

Code:
<%if isBookmarked eq "1"%>alreadybookmarked<%else%>show bookmark link<%endif%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] function isBookmarked? In reply to
Hey Andy,

thx for the code.

I am using version: 3.2.0 and i have the same problem like socrates: The check will be ignored and bookmarked links doesnt shown!

It doesnt matter if i use <%if isBookmarked eq "1"%> or only <%if isBookmarked%>..

Greetings

Coyu
Quote Reply
Re: [Coyu] function isBookmarked? In reply to
Hi,

Can you PM me over GLinks admin details, so I can take a look? The code should work fine :/

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Coyu] function isBookmarked? In reply to
Hi,

My Fault <G>

Should be:

Code:
<%check_bookmarked($ID)%>

Not:

Code:
<%check_bookmarked%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] function isBookmarked? In reply to
YESSS... It works very fine...

Thx!!!! ,-)

Coyu
Quote Reply
Re: [Coyu] function isBookmarked? In reply to
I'm trying to use this application in Links 3.2.0, but having some problems. I don't know, if I'm doing something wrong or have misunderstood the function of the application. My goal is for users to be able to tell at a glance, if they have already bookmarked a link when browsing the categories.

When I view the links in my Bookmarks the application appears to be working. As those indicate they have been bookmarked. But when I view them in the category section, the ones that are bookmarked show no change and are not indicated as being bookmarked.

The following is what I have done:
Created the a global called check_bookmarked using the code supplied in this thread.
Added <%check_bookmarked($ID)%> at the very top of the link.html template.
This is the part that I don't know, if it is correct. I replaced "Bookmark It" with the code in red. <%if config.bookmark_enabled%><a href="<%config.db_cgi_url%>/bookmark.cgi?action=link_add;ID=<%ID%>"><%if isBookmarked%>Bookmarked<%else%>Bookmark It<%endif%></a><%endif%>

EDIT: After posting this I went back and checked some more. The application appears to be working correctly on the dynamic pages, but not the static. Is there something more I can do to make it work on the static pages also?

Last edited by:

kittymother: Feb 27, 2010, 1:11 PM
Quote Reply
Re: [kittymother] function isBookmarked? In reply to
Hi,

The only way you could get it working with static pages, is to use mod_rewrite (which makes the static pages run via page.cgi, while still appearing to be static for the users)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!