readywire Posted April 3, 2009 Share Posted April 3, 2009 I am trying to add an RSS feed to my WHMCS client area. I came across RSS2HTML, a script that pulls RSS data and converts it to HTML. As you can see, it's working just fine on its own: https://secure.readywire.com/rss/rss-blog.php Now, how can I incorporate this php page (rss-blog.php) into a WHMCS template? Someone on the forum suggested that I do the following: {php} include('/path/to/file.php'); {/php} The Smarty documentation suggested that I try this: {include file='/path/to/file.php'} Neither seem to be working and I can't find anything in my Apache error logs to tell me why it's not working. Thanks for your help! 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted April 3, 2009 Share Posted April 3, 2009 google "smarty include php" smarty has aoption to include php files its not like a {php} include(Somthing) {/php} Also check your pathing 0 Quote Link to comment Share on other sites More sharing options...
readywire Posted April 4, 2009 Author Share Posted April 4, 2009 Any hints? None of the following seem to be working {include_php file="/rss/rss-blog.php"}{php} include('/rss/rss-blog.php'); {/php} {include file='/rss/rss-blog.php'} And yes, the path is correct. 0 Quote Link to comment Share on other sites More sharing options...
mylove4life Posted April 4, 2009 Share Posted April 4, 2009 {include_php file="/path/to/somefile.php"} that should do it 0 Quote Link to comment Share on other sites More sharing options...
bear Posted April 4, 2009 Share Posted April 4, 2009 {include_php file="/path/to/somefile.php"} that should do it He's already said he'd tried that twice now, so something more is going on. 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted April 5, 2009 Share Posted April 5, 2009 if you turn error_reporting(E_ALL) on just above the line that does the call you should be able to get some usefull information. 0 Quote Link to comment Share on other sites More sharing options...
mylove4life Posted April 5, 2009 Share Posted April 5, 2009 instead of blasting me tell him what's wrong then.... He's already said he'd tried that twice now, so something more is going on. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted April 5, 2009 Share Posted April 5, 2009 instead of blasting me tell him what's wrong then.... No one blasted you, but it would appear that you hadn't read the thread. I was explaining that to you. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 5, 2009 Share Posted April 5, 2009 To include a php file in your template then the included file is relative to your templates directory only. eg.. from your example {include_php file="/rss/rss-blog.php"} if you have whmcs in a directory (say whmcs) and your file there is in the rss directory in your public_html. The correct way is this {include_php file="../../rss/rss-blog.php"} or you need to specify the full path {include_php file="/home/user/public_html/rss/rss-blog.php"} Hope that helps 0 Quote Link to comment Share on other sites More sharing options...
panamaserver Posted April 5, 2009 Share Posted April 5, 2009 Yes, as SPARKY say. We had the same errors few months ago and we code ii same as sparky explain here and it work. Hope work for you too. 0 Quote Link to comment Share on other sites More sharing options...
Iceman Posted April 5, 2009 Share Posted April 5, 2009 An easier way may be to use the environment variable $DOCUMENT_ROOT rather than trying to work out all the ../../../... etc etc Cheers, Paul 0 Quote Link to comment Share on other sites More sharing options...
readywire Posted April 6, 2009 Author Share Posted April 6, 2009 Bingo! It's working. Thank you for your help, everyone! Shaun, you were correct in your original post. I was defining the wrong path. Thanks to Sparky, I now know that you need to define the FULL path. 0 Quote Link to comment Share on other sites More sharing options...
Austdata Posted May 19, 2009 Share Posted May 19, 2009 I have a similar problem, I am using a PHP include file to standardise my top menu, which works well with the common PHP web pages but wont work with WHMCS Templates. I have tried all the following: {include file='../inc/menu_box-top.php'} {include_php file='../inc/menu_box-top.php'} {insert name='../inc/menu_box-top.php'} {php} include ('../inc/menu_box-top.php'); {/php} To insert this PHP include file. <div id="topMenuBox"> <table width="256" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="80"> <a href="index.php"><img src="images/topMenu_03.jpg" alt="Home" width="80" height="39" border="0" /></a> </td> <td width="84"> <a href="client/clientarea.php"><img src="images/topMenu_04.jpg" alt="Clients Log-In" width="84" height="39" border="0" /></a> </td> <td width="92"> <a href="smf/index.php"><img src="images/topMenu_05.jpg" alt="Forum" width="92" height="39" border="0" /></a> </td> </tr> </table> </div> All I have so far is the alternate text with hyperlinks (at least we know I have the right path ) Anyone know a way to include the HTML stuff in a template and still maintain a common point of change for all code? 0 Quote Link to comment Share on other sites More sharing options...
bear Posted May 19, 2009 Share Posted May 19, 2009 This one you had should work, it works on mine: {php} include ('../inc/menu_box-top.php'); {/php} 0 Quote Link to comment Share on other sites More sharing options...
Austdata Posted May 19, 2009 Share Posted May 19, 2009 It only shows the alt text as a hyperlink, not the images ... Doh! The path for the images is not correct... I'll try using absolute paths in the PHP include file. Thanks very much for the assist. It's always the way, isn't it? As soon as you ask someone else to have a look, you find the mistake and it is always a simple one. Still, it is 2:52AM here. But it is working now!! It has introduced another path problem but I look at that in about 8 hours time. Thanks again Bear, Cheers, Mike 0 Quote Link to comment Share on other sites More sharing options...
BAJI26 Posted May 19, 2009 Share Posted May 19, 2009 Where are the images relative to whmcs? 0 Quote Link to comment Share on other sites More sharing options...
Austdata Posted May 19, 2009 Share Posted May 19, 2009 They're in /home/public_html/images and WHMCS is in /home/public_html/clients but the rest of the sites code is in /home/public_html, hence the problem using a common file. Is there a better way to access all three? Cheers, Mike 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted May 20, 2009 Share Posted May 20, 2009 Use {include_php file="../../inc/menu_box-top.php"} Including files into a template is relative to the templates directory (not the whmcs root) and change your php file to this (using paths relative to the doc root) [color=#000000][color=#007700]<[/color][color=#0000bb]div id[/color][color=#007700]=[/color][color=#dd0000]"topMenuBox"[/color][color=#007700]> <[/color][color=#0000bb]table width[/color][color=#007700]=[/color][color=#dd0000]"256" [/color][color=#0000bb]border[/color][color=#007700]=[/color][color=#dd0000]"0" [/color][color=#0000bb]cellpadding[/color][color=#007700]=[/color][color=#dd0000]"0" [/color][color=#0000bb]cellspacing[/color][color=#007700]=[/color][color=#dd0000]"0"[/color][color=#007700]> <[/color][color=#0000bb]tr[/color][color=#007700]> <[/color][color=#0000bb]td width[/color][color=#007700]=[/color][color=#dd0000]"80"[/color][color=#007700]> <[/color][color=#0000bb]a href[/color][color=#007700]=[/color][color=#dd0000]"/index.php"[/color][color=#007700]><[/color][color=#0000bb]img src[/color][color=#007700]=[/color][color=#dd0000]"/images/topMenu_03.jpg" [/color][color=#0000bb]alt[/color][color=#007700]=[/color][color=#dd0000]"Home" [/color][color=#0000bb]width[/color][color=#007700]=[/color][color=#dd0000]"80" [/color][color=#0000bb]height[/color][color=#007700]=[/color][color=#dd0000]"39" [/color][color=#0000bb]border[/color][color=#007700]=[/color][color=#dd0000]"0" [/color][color=#007700]/></[/color][color=#0000bb]a[/color][color=#007700]> </[/color][color=#0000bb]td[/color][color=#007700]> <[/color][color=#0000bb]td width[/color][color=#007700]=[/color][color=#dd0000]"84"[/color][color=#007700]> <[/color][color=#0000bb]a href[/color][color=#007700]=[/color][color=#dd0000]"/client/clientarea.php"[/color][color=#007700]><[/color][color=#0000bb]img src[/color][color=#007700]=[/color][color=#dd0000]"/images/topMenu_04.jpg" [/color][color=#0000bb]alt[/color][color=#007700]=[/color][color=#dd0000]"Clients Log-In" [/color][color=#0000bb]width[/color][color=#007700]=[/color][color=#dd0000]"84" [/color][color=#0000bb]height[/color][color=#007700]=[/color][color=#dd0000]"39" [/color][color=#0000bb]border[/color][color=#007700]=[/color][color=#dd0000]"0" [/color][color=#007700]/></[/color][color=#0000bb]a[/color][color=#007700]> </[/color][color=#0000bb]td[/color][color=#007700]> <[/color][color=#0000bb]td width[/color][color=#007700]=[/color][color=#dd0000]"92"[/color][color=#007700]> <[/color][color=#0000bb]a href[/color][color=#007700]=[/color][color=#dd0000]"/smf/index.php"[/color][color=#007700]><[/color][color=#0000bb]img src[/color][color=#007700]=[/color][color=#dd0000]"/images/topMenu_05.jpg" [/color][color=#0000bb]alt[/color][color=#007700]=[/color][color=#dd0000]"Forum" [/color][color=#0000bb]width[/color][color=#007700]=[/color][color=#dd0000]"92" [/color][color=#0000bb]height[/color][color=#007700]=[/color][color=#dd0000]"39" [/color][color=#0000bb]border[/color][color=#007700]=[/color][color=#dd0000]"0" [/color][color=#007700]/></[/color][color=#0000bb]a[/color][color=#007700]> </[/color][color=#0000bb]td[/color][color=#007700]> </[/color][color=#0000bb]tr[/color][color=#007700]> </[/color][color=#0000bb]table[/color][color=#007700]> </[/color][color=#0000bb]div[/color][color=#007700]> [/color][/color] If you have seo enabled in whmcs (using base href) then you will need to change the paths in the php file to the full url eg.. https://domain.com/images/topMenu_03.jpg 0 Quote Link to comment Share on other sites More sharing options...
Austdata Posted May 20, 2009 Share Posted May 20, 2009 I thought {include_php} was being depreciated. Otherwise it seemed like the better option, given that it can be cached and {include} can't according to Smarty Net. I understand that the files are relative to the WHMCS template directory but I also use the same file as an include for the non-template web pages, which is a different directory again, closer to the root. I have a feeling I should be using a variable of some kind but my PHP, HTML, Smarty "code", etc knowledge is quite limited. 0 Quote Link to comment Share on other sites More sharing options...
cesiumdeth Posted August 19, 2011 Share Posted August 19, 2011 {php} //getcwd() gets the current working directory //or in the case of the WHMCS templates this //gets the full path to the folder you are running //WHMCS in include (getcwd().'/somefile.php'); {/php} 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.