X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Need help putting code into .tpl file - php rss2 (https://forum.x-cart.com/showthread.php?t=42364)

Madhatterr 09-15-2008 08:47 AM

Need help putting code into .tpl file - php rss2
 
Okay,

I've seen RSS discussions before (there are mods for sale out there) but I thought I might try to do some tweeking myself based off some code another person wrote. I think I've got a pretty hot idea that could work but I'm missing one or two small details that I hope you guys can help me with.

Please take a look at: http://madhatterrgames.com/rss2html.php?XMLFILE=http://madhatterrgames.com/phpBB3/generate_feed.php%3fcont...tml&MAXITEMS=1

That's what the feed will look like at the top of my center/right area on this page (and, because of where I'm putting it in the home.tpl file, all my pages) http://www.madhatterrgames.com/home.php ... on the home.php page it would appear just above the category images.

The code I'd like to put into the home.tpl would look something like this (I think):

Code:

<?php
$XMLFILE = "http://madhatterrgames.com/phpBB3/generate_feed.php?content=posts&f%5B%5D=17&number_items=1&sid=3043e6c2e27b05430edc3ddff7d95c4b";
$TEMPLATE = "http://madhatterrgames.com/sample-template.html";
$MAXITEMS = "1";
include("rss2html.php");
?>


or

Code:

<?php
include("http://madhatterrgames.com/rss2html.php?XMLFILE=http://madhatterrgames.com/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=http://madhatterrgames.com/sample-template.html&MAXITEMS=1");
?>


Initially I tried putting the first in without the <?php tag and the ?> end tag. No dice. Second I tried the same with the second and then with putting { } around hte include command making sure to try it with a space before and after the include command.

All three attempts failed and produced errors. I'm pretty sure I should be able to make this appear in the home.tpl ... I'm just failing in the execution of it. LOL

Could someone please give me a hand with this one. I promise eternal gratitude and cookies if we ever meet face to face. *wink*

-Dee :mrgreen:

Madhatterr 09-18-2008 07:42 AM

Re: Need help putting code into .tpl file - php rss2
 
*polite bump*

Victor D 09-18-2008 08:08 AM

Re: Need help putting code into .tpl file - php rss2
 
Smarty was designed to divide HTML markup and PHP script. So it is not convinient to put PHP scripts into template.
But it is possible
Wrap the PHP code with tags

HTML Code:


{php}
PUT script here
{/php}


Madhatterr 09-18-2008 08:24 AM

Re: Need help putting code into .tpl file - php rss2
 
So it should look like this?

Code:

{php}
<?php
$XMLFILE = "http://madhatterrgames.com/phpBB3/generate_feed.php?content=posts&f%5B%5D=17&number_items=1&sid=3043e6c2e27b05430edc3ddff7d95c4b";
$TEMPLATE = "http://madhatterrgames.com/sample-template.html";
$MAXITEMS = "1";
include("http://madhatterrgames.com/rss2html.php");
?>
{/php}


Madhatterr 09-18-2008 08:33 AM

Re: Need help putting code into .tpl file - php rss2
 
Okay I'm fiddling still (thanks btw for replying!) here's what I've gotten so far in trial and error.


When I put it in like this

Code:

{php}
<?php
$XMLFILE = "http://madhatterrgames.com/phpBB3/generate_feed.php?content=posts&f%5B%5D=17&number_items=1&sid=3043e6c2e27b05430edc3ddff7d95c4b";
$TEMPLATE = "http://madhatterrgames.com/sample-template.html";
$MAXITEMS = "1";
include("http://madhatterrgames.com/rss2html.php");
?>
{/php}


I get this:

Parse error: syntax error, unexpected '<' in /.../public_html/var/templates_c/%%5A^5A2^5A22702C%%home.tpl.php on line 206



When I put it in like this:
Code:

{php}
$XMLFILE = "http://madhatterrgames.com/phpBB3/generate_feed.php?content=posts&f%5B%5D=17&number_items=1&sid=3043e6c2e27b05430edc3ddff7d95c4b";
$TEMPLATE = "http://madhatterrgames.com/sample-template.html";
$MAXITEMS = "1";
include("http://madhatterrgames.com/rss2html.php");
{/php}



I get this:

Parse error: syntax error, unexpected '<' in /.../public_html/var/templates_c/%%5A^5A2^5A22702C%%home.tpl.php on line 206



When I put it in like this:
Code:

{php}
<?php
include("http://madhatterrgames.com/rss2html.php?XMLFILE=http://madhatterrgames.com/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=http://madhatterrgames.com/sample-template.html&MAXITEMS=1");
?>
{/php}



I get this:

Parse error: syntax error, unexpected '<' in /.../public_html/var/templates_c/%%5A^5A2^5A22702C%%home.tpl.php on line 206



When I put it in like this:
Code:

{php}
include("http://madhatterrgames.com/rss2html.php?XMLFILE=http://madhatterrgames.com/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=http://madhatterrgames.com/sample-template.html&MAXITEMS=1");
{/php}


I get this:
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /.../public_html/var/templates_c/%%5A^5A2^5A22702C%%home.tpl.php on line 206

Victor D 09-19-2008 12:47 AM

Re: Need help putting code into .tpl file - php rss2
 
HTML Code:


{php}
include("http://madhatterrgames.com/rss2html.php?XMLFILE=http://madhatterrgames.com/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=http://madhatterrgames.com/sample-template.html&MAXITEMS=1");
{/php}



should not work due to security reasons
You have to specify not the URL of the file, but path to it from the directory where your store is located

Cleanup templates cache with
HTML Code:

http://madhatterrgames.com/pathToYourStore/cleanup.php
in your browser before proceed and try
HTML Code:

{php}
include("rss2html.php?XMLFILE=/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=sample-template.html&MAXITEMS=1");
{/php}


if rss2html.php is located in the folder with your store.

Madhatterr 09-20-2008 06:19 AM

Re: Need help putting code into .tpl file - php rss2
 
Thank You SOOO MUCH for taking your time to help me out with this. :mrgreen:
I did as you instructed and got the following error:

Quote:

Warning: include(rss2html.php?XMLFILE=/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D% 3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430e dc3ddff7d95c4b&TEMPLATE=sample-template.html&MAXITEMS=1) [function.include on line ]: failed to open stream: No such file or directory in /{pathtomystore}/templates_c/%%5A^5A2^5A22702C%%home.tpl.php206

Any other help you can give is greatly appriciated.

-Dee

Victor D 09-21-2008 11:49 PM

Re: Need help putting code into .tpl file - php rss2
 
it's like poking all around without access to your server ;)

One more try:
Place rss2html.php in the root of your webserver and the add just one more slash:
HTML Code:


{php}
include("/rss2html.php?XMLFILE=/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=sample-template.html&MAXITEMS=1");
{/php}


Madhatterr 09-22-2008 07:21 AM

Re: Need help putting code into .tpl file - php rss2
 
LOL, the things we go through for better seo and content. :roll:

Alright, tried the above and got this error:

Quote:

Warning: include(/rss2html.php?XMLFILE=/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D% 3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430e dc3ddff7d95c4b&TEMPLATE=sample-template.html&MAXITEMS=1) [function.include]: failed to open stream: No such file or directory in /home/hortonst/public_html/var/templates_c/%%5A^5A2^5A22702C%%home.tpl.php on line 207

As for your mention of access to our website, any chance you'd be willing to nose around? If so I'd be willing to drop you the information, it might be quicker than this guess work based off my replies (since you seem willing to assist us until we get it right ... did I mention how VERY much I appriciate this?)

Anyway, even if you're not willing... thanks and hopefully we'll get this figured out soon. I'm sure it will be a ton better for our site than the iframe solution I'm using right now.

-Dee

Madhatterr 09-22-2008 08:04 AM

Re: Need help putting code into .tpl file - php rss2
 
For those looking to put an rss feed reader on their page, here's a GREAT & FREE solution: http://www.xcartmods.co.uk/x-cart-rss-feeds-displayer-v4x-x-cart-mods-pr-17.html

Victor, thanks ever so much for your help but it seems someone beat me to the answer on how to do it! :) If I do any successful tinkering with it, I'll post here and share.

YAY!!! :D/

-Dee

Victor D 09-22-2008 08:25 AM

Re: Need help putting code into .tpl file - php rss2
 
The last affort to make it end shedding hardly any blood :)
Insert this somewhere into your template f.e. skin1/customer/home.tpl,
HTML Code:


{php}
echo getcwd();
{/php}


put the script rss2html.php
to directory that will be displayed after viewing this template in browser

clear cache and use this variant

HTML Code:


{php}
include("rss2html.php?XMLFILE=/phpBB3/generate_feed.php%3fcontent%3dposts%26f%255B%255D%3d17%26number_items%3d1%26sid%3d3043e6c2e27b05430edc3ddff7d95c4b&TEMPLATE=sample-template.html&MAXITEMS=1");
{/php}



All times are GMT -8. The time now is 03:16 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.