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

Adding either perl or php into templates

Quote Reply
Adding either perl or php into templates
Hi
I have a decent size directory with .html extensions. I dont want to alter the extension.

I use a third part text ads programme that supplies a small php or perl code to add to my website.

Any Ideas on how to install it into my templates. I cant get the code to work.

It doesn't work if I drop it straight in, and I can't get it to work using template globals.

Thanks
Quote Reply
Re: [babybrands] Adding either perl or php into templates In reply to
Hi,

You are refering to "globals" - are you using Links 2 (static) or LinksSQL/Gossamer Links (SQL) ?

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: [babybrands] Adding either perl or php into templates In reply to
BTW, just had a look and saw you made a post in the Gossamer Links forum. I'm guessing therefore you are using GLinks =)

The first step - is how do they tell you to invoke the PHP or Perl codes?

At its simplest, this kind of global should work:

Code:
sub {
return system(qq|perl /path/to/script.pl|);
}

..or for a PHP script:

Code:
sub {
return system(qq|php /path/to/script.php|);
}

..or possibly you may need the full path to PHP's libs:

Code:
sub {
return system(qq|/usr/bin/php /path/to/script.php|);
}

As I said though, it depends more on what you are trying to call (i.e if its a "chunk" of code, instead of just a system command).

Hope that helps.

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] Adding either perl or php into templates In reply to
Hi, thanks for your help.
I am using Links sql 2.2.1.

I have used the global you provided: sub {
return system(qq|php /path/to/script.php|);
}

I am calling it from include_footer.html template however its not working quite right. The text ads are appearing at the top of the page in the header area, rather than at the bottom.

Secondly when I try to build the static html pages its not showing on any of the pages.

This is the code i need to be working in my template pages:

<?php $DN =""; if(isset($_SERVER['SERVER_NAME'])){$DN = $_SERVER['SERVER_NAME'];}
$PU = ""; $PU = $_SERVER['PHP_SELF']; $S="?";foreach($_GET as $var => $val){$PU .= $S.$var."=".$val; $S="~";}
$FP = @fopen("http://dlaserv.com/...=$DN&PageUrl=$PU", "r");
$PG ="";while ($TX = @fread($FP, 100)) {$PG .= $TX;}
echo("$PG"); ?>

Hope you can offer a bit more advice.

Thanks
Quote Reply
Re: [babybrands] Adding either perl or php into templates In reply to
Hi,

Do you have a URL where I can see it happening?

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] Adding either perl or php into templates In reply to
Hi, yes here is the dynamic version of the page before I build the static pages with .html extension.

http://www.findhd.com/...rectory/page.cgi?d=1

The link advert is at the very top of the page called Bike Locks. If you look down towards the footer there is a "0" in grey.

This is where the advert should be.

Just to confirm I am doing things right.:

Global is named "direct_link" and includes the following.
: sub { return system(qq|php /home/findhd/public_html/directory/direct_link.php|); }

And I have added it in "includes_footer.html" like this: <td align="center"><%direct_link%></td>

Thanks again for your time.
Quote Reply
Re: [babybrands] Adding either perl or php into templates In reply to
Hi,

Could you PM me your include_header.html and include_footer.html templates please? If you put that code in the footer, it seems a bit odd that its showing up right at the top :|

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: [babybrands] Adding either perl or php into templates In reply to
Hi,

Please try this global:

Code:
sub {
return `qq|php /path/to/script.php|`;
}

From the templates you sent me, it all seems to be in the correct place - but I've got a feeling its something to do with the way the system() command is being called. I'm hoping that the backticks (`) will work better :)

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] Adding either perl or php into templates In reply to
Still not working Crazy.

I'm sure you have more important tasks, but if any solution comes to mind let me know.

Cheers
Quote Reply
Re: [babybrands] Adding either perl or php into templates In reply to
Hi,

If you don't mind sending over your admin panel login details, I'll take a look later on for you. Its not a very simple one to try and debug over a forum :( (it probably will be once we know the problem - but not til then =))

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: [babybrands] Adding either perl or php into templates In reply to
Hi,

All done =)

It was a boo-boo from my end, when I gave you the last global. It should have read:

Code:
sub {
return `php /home/findhd/public_html/direct_link.php`;
}

<G>

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] Adding either perl or php into templates In reply to
Job Done.
I have two other link sql directories, so this will save me alot of time doing the same task.
Thanks for the help
Sly
Post deleted by PerlFlunkie In reply to