Jump to content

PHP in smarty templates using {php}


alexasigno

Recommended Posts

Hi everyone, I would be most appreciative if someone could help me, i am trying to use the following piece of code into a smarty template which is causing a problem.

 

This code is to be used to display a different rss feed depending on the page, hence there will be multiple versions of this. Ie if its a skiing page show this, if its a snowboarding page show this etc.

 

<?php
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

if ( $URL == "http://www.alexasigno.co.uk/travel/" | $URL == "http://www.alexasigno.co.uk/travel/index.php") : ?>

<?php function add_filter($a,$b) { }; // this is a function that WordPress normally provides
define("ABSPATH",'./'); // this is a constant that WordPress normally provides
include 'inlineRSS.php'; // this is the unmodified inlineRSS.php file
inlineRSS('travel'); // and finally, this is the call to your feed
?>

<?php endif; ?>

 

I have tried using the code in these tags {php} but i still cant get it to work, here is what i tried:

 

 

<?php
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

if ( $URL == "http://www.alexasigno.co.uk/travel/" | $URL == "http://www.alexasigno.co.uk/travel/index.php") : ?>

<?php function add_filter($a,$b) { }; // this is a function that WordPress normally provides
define("ABSPATH",'./'); // this is a constant that WordPress normally provides
include 'inlineRSS.php'; // this is the unmodified inlineRSS.php file
inlineRSS('travel'); // and finally, this is the call to your feed
?>

<?php endif; ?>



{php}
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
if ( $URL == "http://www.alexasigno.co.uk/travel/ski_holidays/" : {/php}

{php} function add_filter($a,$b) { }; // this is a function that WordPress normally provides
define("ABSPATH",'./'); // this is a constant that WordPress normally provides
include 'inlineRSS.php'; // this is the unmodified inlineRSS.php file
inlineRSS('ski'); // and finally, this is the call to your feed
{/php}

{/php}

 

It would be great if your are able to help or shed any ideas.

 

Many thanks

Alex

Link to comment
https://forums.phpfreaks.com/topic/58813-php-in-smarty-templates-using-php/
Share on other sites

  • 1 month later...

Well i still cant get this sorted, i have refined the code slightly and it still just wont work within a smarty template. The following code works fine as a php file, how should i mark this up to work correctly?

 

Many thanks

 

<?php
$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
if ( $URL == "http://www.code-d.com/test.php" | $URL == "http://www.code-d.com/test.php"){

function add_filter($a,$b) { }; // this is a function that WordPress normally provides
define("ABSPATH",'./'); // this is a constant that WordPress normally provides
include 'inlineRSS.php'; // this is the unmodified inlineRSS.php file
inlineRSS('travel'); // and finally, this is the call to your feed

}

$URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
if ( $URL == "http://www.code-d.com/test2.php" | $URL == "http://www.code-d.com/test2.php"){

function add_filter($a,$b) { }; // this is a function that WordPress normally provides
define("ABSPATH",'./'); // this is a constant that WordPress normally provides
include 'inlineRSS.php'; // this is the unmodified inlineRSS.php file
inlineRSS('ski'); // and finally, this is the call to your feed

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.