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

url of <%title_linked%> -question

Quote Reply
url of <%title_linked%> -question
Hi,

does anyone know how I can change the URL from the <%title_linked%>-tag from an absolute to a relative path ?

The reason why I ask this is that my directory is build at http://www.mydomain.com .

But I also have some sub-domains pointing to the same directory (example http://sub.mydomain.com)

So wat happens is that when I'm browsing my directory by using http://sub.mydomain.com all <%title_linked%>-tags are pointing back to http://www.mydomain.com/.../... instead of pointing to http://sub.mydomain.com/.../...

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
Just make a new global, and use some regex to change the URL in the code. Example given here;

http://www.gossamer-threads.com/...orum.cgi?post=193398

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] url of <%title_linked%> -question In reply to
Thanks,

i didn't found this post, but it doesn't work properly,

If I create the global

sd_title_linked:

sub {
my $vars = shift;
my $title_linked = $vars->{title_linked};
$title_linked =~ s|^\s+<[^>]+>|<a href="http://www.ace-installer.com">|;
return $title_linked;

}


it works for the main-page in <%title_linked%> but not for the subcategories!

There is a tag called <%URL%> in subcategory.html but somehow it doesn't work if I create another global:

sd_URL:

sub {
my $vars = shift;
my $URL = $vars->{URL};
$URL =~ s|^\s+<[^>]+>|<a href="http://www.ace-installer.com">|;
return $URL;

}








Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
ok,

I think it has to do something with Build.pm.

-> sub build_title_linked

I tried to write a short Plugin with a PRE hook in build_title_linked running LAST (where I have deleted the red marked code from the original sub) but I always get an error:




# ==================================================================
# Plugins::BuildPathNew - Auto Generated Program Module
#
# Plugins::BuildPathNew
# Author : Manuel Kester
# Version : 1.0
# Updated : Fri Dec 13 14:23:32 2002
#
# ==================================================================
#

package Plugins::BuildPathNew;
# ==================================================================

use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;

# Inherit from base class for debug and error methods
@Plugins::BuildPathNew::ISA = qw(GT::Base);

# Your code begins here! Good Luck!


# PLUGIN HOOKS
# ===================================================================


sub build_title_linked {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'build_title_linked'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#


my $input = shift;
my $complete = 0;
my $home = 1;
if (ref $input) {
$complete = $input->{complete} || 0;
$home = defined $input->{home} ? $input->{home} : 1;
$input = $input->{name};
}
my (@dirs, $dir, $output, $path, $last, $db, $top);

$db = $DB->table('Category');
$top = Links::language('LINKS_TOP') || 'Top';

@dirs = split (/\//, $input);
$last = pop @dirs unless ($complete);
$output = $home ? qq| <a href="$CFG->{build_root_url}/$CFG->{build_index}">$top</a> :| : '';
for (0 .. $#dirs) {
$path = "/" . $db->as_url ( join "/", @dirs[0 .. $_] );
$output .= qq| <a href="$CFG->{build_root_url}$path/$CFG->{build_index}">$dirs[$_]</a> :|;
}
if ($complete) {
chop $output; chop $output;
}
else {
$output .= " $last";
}
return $output;
}

# Always end with a 1.
1;






Any comments?

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
This

$title_linked =~ s|^\s+<[^>]+>|<a href="http://www.ace-installer.com">|;

will only change the first url in title linked. If you want to change all of them to relative urls you would need to change it a bit. Something like this?

$title_linked =~ s|<a href="http://www.ace-installer.com/?(.*?)">|<a href="/$1">|g;

Laura.
The UK High Street

Last edited by:

afinlr: Dec 13, 2002, 5:22 AM
Quote Reply
Re: [afinlr] url of <%title_linked%> -question In reply to
thanks for your reply, but this doesn't work!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
Well I just tried it on my site and it seems to work.Unsure

sub {
my $vars = shift;
my $title_linked = $vars->{title_linked};
$title_linked =~ s|<a href="http://www.ace-installer.com/?(.*?)">|<a href="/$1">|g;
return $title_linked;
}


Maybe I haven't understood what it is you are trying to do? This should replace every occurence of

<a href="http://www.ace-installer.com/something">

with

<a href="/something">

If that's not what you're trying to do can you have another go at explaining it?

Laura.
The UK High Street
Quote Reply
Re: [afinlr] url of <%title_linked%> -question In reply to
I interpretted it the same way as you, however I'd do it like:

Code:
sub {
(my $title_linked = $_[0]->{title_linked}) =~ s|<a href="http://[^/]+([^"]+)">|<a href="$1">|g;
return $title_linked;
}

Not tested so it may be totally wrong ;)
Quote Reply
Re: [Paul] url of <%title_linked%> -question In reply to
Will this work for <a href="http://www.ace-installer.com">?

Don't you need to add the / in for this?
Quote Reply
Re: [Paul] url of <%title_linked%> -question In reply to
Edit: I have that all wrong.

Last edited by:

Paul: Dec 13, 2002, 8:34 AM
Quote Reply
Re: [afinlr] url of <%title_linked%> -question In reply to
o.k, once again.

what I want to do is the following

My directory is at

http://www.shop-netz.de/

Now I want to use another template (not my default one):

http://www.shop-netz.de/...i?t=beispiel&d=1

and a subdomain (http://unicum.shop-netz.de) which is in fact exactly the same as http://www.shop-netz.de .

AND NOW all the titles in the title_link - row should point to

http://unicum.shop-netz.de/cgi-bin/shop/page.cgi?g=index.html&t=beispiel&d=1

or

/cgi-bin/shop/page.cgi?g=index.html&t=beispiel&d=1

and NOT to

http://www.shop-netz.de/cgi-bin/shop/page.cgi?g=index.html&t=beispiel&d=1


The global above works static put should generate an output for DYNAMIC MODE!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.

Last edited by:

ManuGermany: Dec 13, 2002, 9:21 AM
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
How about making it simple and doing:

s#http://www#http://unicum#g;
Quote Reply
Re: [Paul] url of <%title_linked%> -question In reply to
Could you please post me the complete sub ?!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
Ok - and this doesn't work? This shouldn't make any difference whether you are using static or dynamic.

sub {
my $vars = shift;
my $title_linked = $vars->{title_linked};
$title_linked =~ s|<a href="http://www.shop-netz.de/?(.*?)">|<a href="/$1">|g;
return $title_linked;
}

I've had a quick look at your site and you do seem to have the global working sometimes - it keeps changing so you're obviously playing around with it at the moment Crazy
Quote Reply
Re: [afinlr] url of <%title_linked%> -question In reply to
ok,

I've figgured out to problems :

1. Using the sub only static links will be build an not dynamic ones

have a look here (dynamic mode but static links):

http://unicum.shop-netz.de/...p;t=beispiel&d=1



2. I need to replace the urls of the category-listings too

(http://www.shop-netz../ => http://unicum.shop-netz.de) and I don't know how to do this

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.

Last edited by:

ManuGermany: Dec 13, 2002, 10:48 AM
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
Wow, this is much more complicated than it first looked!

I'm afraid its beyond me at the moment. I think you just need to make the replace statement a bit more complicated to include the template and dynamic options as an add on. Hopefully someone else can help you!

I think the subcategories can use a very similar global once you get it working.
Quote Reply
Re: [afinlr] url of <%title_linked%> -question In reply to
Yes that's right.

I didn't think either that it is that complicated for it's a simple thing what I want to do (use relative links or replace a domain name by another one)

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
o.k replacement works in parts with this two subs:



sd_category:

sub {
my $vars = shift;
my $category = $vars->{category};
$category =~ s|www.shop-netz.de|unicum.shop-netz.de|g;
return $category;
}


sd_title_linked:

sub {
my $vars = shift;
my $title_linked = $vars->{title_linked};
$title_linked =~ s|www.shop-netz.de|unicum.shop-netz.de|g;
return $title_linked;
}


THE PROBLEM IS:

Only STATIC LINKS will be build even if you are in DYNAMIC MODE

See here:

http://www.shop-netz.de/...p;t=beispiel&d=1

and here:

http://www.shop-netz.de/...p;t=beispiel&d=1

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
WinkCoolCoolCoolYeah got it! It's not clean programming but it works:



sd_category:

sub {
my $vars = shift;
my $category = $vars->{category};
$category =~ s|www.shop-netz.de|unicum.shop-netz.de|g;
$category =~ s|shopping/|cgi-bin/shop/page.cgi?g=|g;
$category =~ s|">|&d=1&t=beispiel">|g;
return $category;
}


sd_title_linked:

sub {
my $vars = shift;
my $title_linked = $vars->{title_linked};
$title_linked =~ s|www.shop-netz.de|unicum.shop-netz.de|g;
$title_linked =~ s|shopping/|cgi-bin/shop/page.cgi?g=|g;
$title_linked =~ s|">|&d=1&t=beispiel">|g;
return $title_linked;
}

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
Well done Smile

That's just what I was trying to do but my brain gave up last night. Funny how easy it looks when you've done it!

Laura.
The UK High Street
Quote Reply
Re: [ManuGermany] url of <%title_linked%> -question In reply to
In the first part of your regexs change . to \.

. is a special meta-character in regexs.