Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 07-28-2005 06:56:35

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Calling A Php Or Ssi Script From The Cgi Code?

Hi,

I am trying to get an rss feed program to work with ccp5.1. The RSS feed program can place an rss feed on a webpage using dynamic keywords. I am trying to get the feed displayed on each store category page using each category name for the rss feeds keywords. The rss feed program provides a choice of either PHP or SSI codes to call the program that puts the rss feed on the page.

The codes provided are either:

Code:

<?PHP
$keyword = "%KEYWORD%";
include("/home/pmqneqmg/public_html/rss/rss.php");
include("/home/pmqneqmg/public_html/rss/track.php");
?>

or

Code:

<!--#include virtual="/rss/rss.php?keyword=%KEYWORD%" -->
<!--#include virtual="/rss/track.php?keyword=%KEYWORD%" -->

When I place either of these codes in the CCP category template page the code is simply output 'as is' in the html code and does not actually execute and 'convert' to the rss feed html code. I understand this is something to do with the way the CCP pages are dynamically created by the Pearl/CGI code.

To try and work arround this I tried creating a subroutine in the ste_cat.pl file to call the rss feed that way. This subroutine contained the following code:

Code:

#######################################################################
# Ste Cat News                                                  #
#######################################################################

sub ste_cat_news {

&initialize_sub_add('ste_cat_news');

#########
######### This routine displays the RSS News
######### 
######### 
#########

print <<ENDOFTEXT;
<!--#include virtual="/rss/rss.php?keyword=$category_name" -->
<!--#include virtual="/rss/track.php?keyword=$category_name" -->
ENDOFTEXT

&initialize_sub_remove('ste_cat_news');

} ######### End of subroutine.

I call the subroutine from the store category template with:

Code:

(CGIGET TYPE="SUB" VALUE="ste_cat_news")

However this has had the same effect as simply placing the code in the template page in that the code just appears as is in the html code output in the browser.

To see what the rss feed should be doing have a look at this static html page on the site:

To see what is happengin when I try to get the code to work with CCP click here and scroll down to where is says '' (the feed should appear just below that):  (view the source of this page and you'll see the code is there in tact but not executed as in the other link above)


So If anyone knows how to successfully use the PHP or SSI code to call the RSS feed program from the CCP5.1 code please do let me know as this is something I really want to get implemented on my site. I think it is simply in knowing how to use PHP or SSI with CGI script, I may be totaly of the mark though as my knowledge in CGI is next to none!

On a side note... if anyone is interested in SEO they should seriously think about getting RSS feeds on their site as constantly updating content is valued highly by the search engines and will get them to index your sites faster and more frequently plus your sites will likely get better ranikings because of it.

many thanks in advance for any help with this :-)


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#2 07-29-2005 17:05:22

kaz
Member
Registered: 05-19-2004
Posts: 583

Re: Calling A Php Or Ssi Script From The Cgi Code?

I would try putting the SSI code in a separate .shtml file and either call it via popup (like the XL images are displayed) or within a frame if it has to be on the same page.


Kevin Zaleski -  -

Offline

 

#3 07-29-2005 19:46:25

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Thanks for the help Kaz although I'm idealy looking for a solution that can have the rss feed reside on the category page so that the rss content can be indexed by search engines and so that the "$category_name" CCP variable for category names can be used as dynamicaly changing keyword(s) which pull the relevant rss content on each seperate page. This also means the whole feed setup would from then on not require any fiddling with as it would totaly self running... i.e. if I create new categories or modify existing category names the rss feeds would change to suit automatically.

I currently have the correct code for the .htaccess file which allows php or ssi to be executed from an html page so hopefully this should all be possible... I hope!! :-)

Anyone got any ideas?

I really think this would be a useful thing for all CPP owners as getting search engines back to websites for frequent re-indexing using constantly chainging rss feeds is a valuable SEO technique. (Frequently changing keyword relevant content increases search engine rankings.)


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#4 08-19-2005 10:37:05

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

If you use the SSI method, you will need to set up Apache server to parse .cgi files as SSI.  This would be done with the configuration directive:

AddOutputFilter INCLUDES .cgi

To execute PHP from within CCP, you would probably want to create a Perl routine and use LWP to call up the script virtually.  Assuming you add the routine to the ste_exec.pl file in the ./cgi-bin/library/modules directory like so:

Code:


sub ste_exec_phprss {

use LWP::Simple;

$php_output = get('http://www.yourdomain.com/rss.php');

print "$php_output";

}

You could call it up from any element (including your layout) using:

(CGIGET TYPE="SUB" VALUE="ste_exec_phprss")

Your rss.php PHP script would be located in your root web directory and have the content:

Code:


<?PHP
$keyword = "%KEYWORD%";
include("/home/pmqneqmg/public_html/rss/rss.php");
include("/home/pmqneqmg/public_html/rss/track.php");
?>


Nick Hendler

Offline

 

#5 08-19-2005 10:47:33

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Thanks so much Nick  :-)

I've been wanting to get this implemented for a while now.

I'll try out what you posted and post back the results.

Thanks again Nick!  :-) 


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#6 08-19-2005 15:25:12

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

No problem smile


Nick Hendler

Offline

 

#7 08-20-2005 14:26:56

davediamond
Member
Registered: 07-16-2003
Posts: 87

Re: Calling A Php Or Ssi Script From The Cgi Code?

webmaster,08/19/2005 10:37:05 AM wrote:

To execute PHP from within CCP, you would probably want to create a Perl routine and use LWP to call up the script virtually.  Assuming you add the routine to the ste_exec.pl file in the ./cgi-bin/library/modules directory like so:

Code:


sub ste_exec_phprss {

use LWP::Simple;

$php_output = get('http://www.yourdomain.com/rss.php');

print "$php_output";

}

You could call it up from any element (including your layout) using:

(CGIGET TYPE="SUB" VALUE="ste_exec_phprss")

Your rss.php PHP script would be located in your root web directory and have the content:

Code:


<?PHP
$keyword = "%KEYWORD%";
include("/home/pmqneqmg/public_html/rss/rss.php");
include("/home/pmqneqmg/public_html/rss/track.php");
?>

Nick,

This works beautifully for calling PHP includes in my cart. I've been searching for a solution like this for quite a while.

If you were standing here my wife would kiss you.  :-) 

Offline

 

#8 08-20-2005 14:50:09

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

It works perfectly  :-)  However...

The main purpose of this is the be able to display category specific news on each category page. In order to do this I need to pass the category name through the url in the subroutine code:

Code:

sub ste_exec_phprss {

use LWP::Simple;

$php_output = get('http://www.pandorastocks.com/rss.php?phrase=$category_name');

print "$php_output";

I have tried it using the technique above but the phrase 'category_name' gets passed through the url instead of the actual current category name... 'computer accessories' for example.

Does any one know the code to add to this subroutine so it passes the current category name as the variable in the url?


In case anyone is interested I got the code in the rss.php file to pick up the url passed variable fine. This is the code:

Code:

<?PHP
$keyword = "$_GET[phrase]";
include("/home/pmqneqmg/public_html/rss/rss.php");
include("/home/pmqneqmg/public_html/rss/track.php");
?>

Thanks for any help in advance!  :-) 


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#9 08-20-2005 15:15:05

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Also am I right in saying that as some of the category names contain spaces in order for the category name to be passed through the url successfully a '' parameter needs to be implemented at some point?


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#10 08-20-2005 15:44:36

davediamond
Member
Registered: 07-16-2003
Posts: 87

Re: Calling A Php Or Ssi Script From The Cgi Code?

myqee,08/20/2005 02:50:09 PM wrote:

$php_output = get('http://www.pandorastocks.com/rss.php?phrase=$category_name');

Nick's code will only include the given contents not execute it. In order to display $category_name, PHP would need to execute the code. So you won't get category names per se.

Offline

 

#11 08-20-2005 17:14:06

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Thanks for the help Dave.

The thing is though is that in the code you show if I just substitute '$category_name' with any text this is what is passed through the url to the PHP script. And it works, it changes the rss feed content accordingly. So if I could get the subroutine that creates the url with the current category name in where I have '$category_name' then every category page will display relevant news based on the category name text.

Shurley there is a way in the subroutine to get the current category name in to that url?

I've got this far I'm not gonna give up now  :-) 


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#12 08-22-2005 08:32:17

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Try this:

Code:


sub ste_exec_phprss {

use LWP::Simple;

$php_output = get("http://www.pandorastocks.com/rss.php?phrase=$category_name");

print "$php_output";

Notice the use of double quotes in the get call - instead of single quotes.  In Perl, anything in single quotes is considered literal and anything in double quotes is interpolated.


Nick Hendler

Offline

 

#13 08-22-2005 10:02:03

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Cheers Nick!

I owe you a beer or two!!  :-)

It's 100% up and running... if anyone is interested in the results have a look at the bottom of any category at my store. Each category now has related current news displayed at the bottom of each category page. This frequently changing related content should bring the search engine spiders back to my site more frequently and also help increase ranking... hopefully!!

It's working well on this category page in particular:

Thanks for all the help... it's a good Monday for a change!

:-) 


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#14 08-22-2005 10:11:02

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Excellent!


Nick Hendler

Offline

 

#15 08-22-2005 11:16:00

davediamond
Member
Registered: 07-16-2003
Posts: 87

Re: Calling A Php Or Ssi Script From The Cgi Code?

Well, I stand corrected. Back to the PHP books for me.  smile 

Offline

 

#16 08-22-2005 11:24:25

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

What's the problem now?  Is it related to special characters or spaces in the category name?  If so, you may want to try:

Code:



sub ste_exec_phprss {

use LWP::Simple;

$category_name_encoded = vars_urlencode($category_name);

$php_output = get("http://www.pandorastocks.com/rss.php?phrase=$category_name_encoded");

print "$php_output";


Nick Hendler

Offline

 

#17 08-23-2005 17:25:58

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

err... no it's working fine.. I think you may have had too many coffee's!!  wink

I think you mistook davediamond's post for mine...

It was all up and running ok and still is... so I still owe you beer!!!  :-)

Thanks again Nick.


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#18 08-23-2005 23:01:27

davediamond
Member
Registered: 07-16-2003
Posts: 87

Re: Calling A Php Or Ssi Script From The Cgi Code?

Perhaps Nick thought I meant that his code didn't work when I said, "back to the PHP books." Sorry. I meant I have to brush up on my PHP references.

Offline

 

#19 08-24-2005 09:59:41

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Yeah, I thought you meant it wasn't working.  Glad we're all good smile


Nick Hendler

Offline

 

#20 09-11-2005 19:27:58

sdonn
Member
Registered: 07-03-2004
Posts: 78

Re: Calling A Php Or Ssi Script From The Cgi Code?

Thanks for the information in this feed.  I have been trying to get an rss feed working on my wwwpsptree.co.uk website but had not managed it until now.  Thanks to the chap who posted this article.  It works now like a treat!

Offline

 

#21 09-30-2005 19:28:26

Jess
Member
Registered: 08-09-2004
Posts: 54

Re: Calling A Php Or Ssi Script From The Cgi Code?

Have you all found that the feed helped with your SEO?

Thanks,
Jess

Offline

 

#22 10-01-2005 06:32:52

myqee
Member
From: London - UK
Registered: 11-11-2004
Posts: 55
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

Hi Jess,

I haven't been monitoring my site rankings (like I should be doing) but I can say since I added the RSS feeds to my pages I have seen an increase in the frequency the search engine bots visit my site and subsequently an increase in the number of pages indexed by the search engines. This has resulted in an increase in traffic... the more pages you have have in the search engines the more traffic you should receive (especially if you've done your other on-page-optimization).

In theory search engines like sites/pages that are updated frequently and contain fresh content. This, according to SEO experts, is supposed to give your pages higher rankings and cause the search engine crawlers to visit your site more frequently; very handy if you make product updates and/or changes and want them to be 'noticed' by the search engines quickly. As well as this the additional content on your site from the RSS feeds provided more text for people to find your site with.

All in all a good idea  wink

If you want to get an RSS feed program to achieve this with CCP. I use this one on my site: .

It works great and goes beyond what most other RSS feed scripts do out there; such as providing visitor tracking statistics which is useful for monitoring traffic on your site.

Plus you wont need to figure out how to implement it in your CCP site because it's all here in this very thread.  smile 


myqee
_____________________________________________________________



  <-- My CCP Shop!
_____________________________________________________________

Offline

 

#23 11-18-2005 21:14:47

jimbo
Member
Registered: 11-15-2004
Posts: 56

Re: Calling A Php Or Ssi Script From The Cgi Code?

Can someone please help understand what this mean:

"If you use the SSI method, you will need to set up Apache server to parse .cgi files as SSI. This would be done with the configuration directive:

AddOutputFilter INCLUDES .cgi"

where and how do I config this ??

Please help...Thanks!

Offline

 

#24 11-18-2005 21:27:50

jimbo
Member
Registered: 11-15-2004
Posts: 56

Re: Calling A Php Or Ssi Script From The Cgi Code?

never mind, i got it to work....sorry

Offline

 

#25 01-24-2007 05:30:57

paulc
Member
From: Bristol, England
Registered: 12-15-2005
Posts: 18
Website

Re: Calling A Php Or Ssi Script From The Cgi Code?

I have just implemented this code with some changes and it works great. But I am having trouble with the $category_name variable.

in ste_exec

Code:

#######################################################################
# Ste Exec Category RSS News                                          #
#######################################################################

sub ste_exec_catrssnews {

use LWP::Simple;

$php_output = 

get("http://www.newsfeedmaker.com/feed_advanced_html.php?keywords=$category_name&num=3&c

ode=40212b93&abstract=1&same_window=&nfm_block=background-color%3A%23FFFFFF%3Bnfm%3AH9pt

%3B&nfm_article=padding%3A0.5em+1em%3Bmargin%3A0px%3B&nfm_article_title=color%3A%23E1771

E%3Bnfm%3Au11px%3B&nfm_article_abstract=color%3A%23808080%3Bnfm%3A9px%3B&nfm_article_dat

e=color%3A%23333333%3Bnfm%3A9px%3B&nfm_more=color%3A%23E1771E%3Bnfm%3A9px%3B&nfm_morelin

k=color%3A%23E1771E%3Bnfm%3Au9px%3B&nfm_article_link=color%3A%23E1771E%3Bnfm%3Au9px%3B")

;

print "$php_output";

}

And in my ste_cat

Code:

(CGIGET TYPE="SUB" VALUE="ste_exec_catrssnews")

This works greta and delivers 3 news stories from wwwnewsfeedmaker.com (visit to tweak the look of your feed)

The only problem I have is that some of my Categories have Sub Categories, and the news feed only delivers the news relating to the last sub category listed (see my IPOD/MP3 Category or iPod Shuffle Category.

sad

I would really appreciate some help on this one.

Paul

Last edited by paulc (01-24-2007 18:02:58)


Paul C
- iPod, PS2, Xbox, Gamecube, PC, Mobile Accessories

Offline

 

Board footer