Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Active Text / Title URL link global

Quote Reply
Active Text / Title URL link global
I have a closed links database (no external links) and use the Title field for the manufacturers name (the URL field for the product). I've sen this thread and wondered if I could do something similar to link the Title to the manufacturers website?

I think I'm after something like this:

Code:
if
Title = Adam then <a href="http:///www.adams-site.com">
else
Title = Brian then <a href="http://www.brians-site.com">
else
do not display a link
endif

Is a global the correct route or am I looking in the wrong place for this kind of thing?
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
I think I've sorted this one another way.

I've created a custom template called web_link.html and used the following:

Code:
<%if Title eq 'Adam'%><a href="http:///www.adams-site.com">Adam's Website</a>
<%elseif Title eq 'Brian'%><a href="http://www.brians-site.com">Brian's Website</a>
<%else%>
<%endif%>

Then on the detailed page I've just linked to this with:

Code:
<%include web_link.html%>

It seems to be doing what I was looking for but if anyone has a better way of doing this please let me know.
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
I'm really not sure what you are doing, or trying to do, but my first few websites were "closed" and required all sorts of internal links/jumps and the fist programs I modified were jump.cgi and page.cgi and created the detail_page.cgi and it's derivatives.


If you have only a few manufacturers, your if/else would work.

The more you have, the more difficult it is to maintain.

The best way would be to have an attached table for manufacturers, and link them via the title field, etc... eg: normalization. But that would take work.

If you are not worried about that, why not add the URL you want to jump to _in_ the link record itself, such as Website, so you can call that variable with <%Website%> and then do something like:

<%if Website%>
<a href="<%Website%>"><%Title%></a>
<%else%>
<%Title%>
<%endif%>

That would link the URL to the title if the URL existed, otherwise just print the title.
if you don't want the unlinked to shown, just rmove the "<%else%><%Title%>"

You could use the SQL monitor to do mass updates if the URL for the manufacturer changed, and you would have the flexibility to offer different products to jump/link to different parts of the manufacturers website(s) with virtually no additional template or other changes.

I might be missing something, but large if/else statements are a last resort, not usually the "best" tool.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Active Text / Title URL link global In reply to
Thanks for the reply.

If I added a field the the database table and called it Website, do you know what SQL command would I use to autopopulate the records? I don't want to have to do 3,000+ manually.

Thanks.
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
The other thing is that I don't want to use the existing <%Title%> to display the link. I want to use a separate value so the displayed title isn't affected.

You can see an example of how I'm currently doing this here.

My format is:

<%Title%> = Manufacturer
<%URL%> = Product Number (internally linked)

then

<%Website%> = Would be the separate link the the manufacturer.

Hope this makes it a little clearer.
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
MJB wrote:
Thanks for the reply.

If I added a field the the database table and called it Website, do you know what SQL command would I use to autopopulate the records? I don't want to have to do 3,000+ manually.

Thanks.

What field did you add, and what field do you want it populated from? (can't be arsed to read the whole thread Shocked)

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] Active Text / Title URL link global In reply to
I haven't added a filed yet as my current method doesn't need one.

I will add a field titled Website and I want to populate it from Title.

Thanks

Last edited by:

MJB: Sep 13, 2010, 6:34 AM
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Ok, well its pretty simple;

1) Add your new field :)
2) Run this query to populate it:

UPDATE glinks_Links SET Website = Title

Thats it Smile

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] Active Text / Title URL link global In reply to
But surely that would just enter the same data of the Title field in to the Website field, not the website URL for that manufacturer?
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Erm, you said this ;)

Quote:
I will add a field titled Website and I want to populate it from Title.

The way I read that, you were saying you wanted to place the value of "Title" into the new "Website" field , for each link .... or am I mis-understanding it?

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] Active Text / Title URL link global In reply to
Yes, sorry, I forgot that you couldn't be arsed to read the whole thread. Laugh

If the 'Title' is 'Adam' I want the 'Website' field to show the URL to Adams website - http://www.adamswebsite.com

So (and not knowing how SQL commands are formatted) it probably needs a command like "UPDATE glinks_Links SET Website (Title = Adam then http://www.adamswebsite.com)"

Possible?
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Mmm, not sure that can be done with a SQL command.

You probably need a script that will go through each link, and then some conditions in it, which would then decide what value to put

Is the website just gonna be grabbed from the URL field?

For example, if URL is:


http://www.somesite.com/product_page.html

...then website holds

http://www.somesite.com/

Is that right? If so, thats not too hard to do (still, wouldn't be possible via SQL, but would need a little script to do it)

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] Active Text / Title URL link global In reply to
No. All links are internal to Detailed pages so there are currently no URL details in the database.

If you see the second post in this thread you can see how I am achieving it now but pugdog made a post earlier today suggesting that my method is not the best way to do this.
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Ok, well not that simple (as will require doing for ALL of the different types) .. but try:

UPDATE glinks_Links SET Website = "http://www.adamssite.com" WHERE Title = "Adam"

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] Active Text / Title URL link global In reply to
Before I do this.......

Every time I add a new link I presume that I'll have to enter the Website details manually for that link whereas at the moment I don't need to do anything. Currently, as soon as I enter a link the website link relating to that product appears on the details page automatically. It just seems like more unnecessary work to me. Unsure
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Why not use a global then? :)

get_website_name
Code:
sub {
my $title = $_[0];
if ($title eq "Andy") {
return qq|http://www.andys-site.com|;
} elsif ($title eq "Fred") {
return qq|http://www.fredssite.com|;
} elsif ($title eq "Joe") {
return qq|http://www.joessite.com|;
}
}

Call with:

<%get_website_name($Title)%>

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: Sep 13, 2010, 9:51 AM
Quote Reply
Re: [Andy] Active Text / Title URL link global In reply to
Now that's more like it. Wink
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Well that doesn't work. It doesn't display anything. Frown
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Sorry, was rushing it =)

Should be:

Code:
my $title = $_[0];

(I've corrected the post above)

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] Active Text / Title URL link global In reply to
Thanks Andy.

I just popped this on the end:

Code:
else { return qq|NA|; }

So, just out of interest, why is using a global better than calling it from a template like I was doing below?

Code:
<%if Title eq 'Adam'%><a href="http:///www.adams-site.com">Adam's Website</a>
<%elseif Title eq 'Brian'%><a href="http://www.brians-site.com">Brian's Website</a>
<%else%>NA
<%endif%>
Quote Reply
Re: [MJB] Active Text / Title URL link global In reply to
Hi,

Doing it from a template means it has to store ALL of those options .. where as a global is much smaller - and in terms of the .compiled template file, it will be quicker to process.

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!