Jump to content

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

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.