Guest Jon Bartus Posted September 15, 2008 Share Posted September 15, 2008 Hi all, Not positive this belongs here but I figured this was my best shot. My client wants me to add a poll to the sidebar on his site and being naturally lazy I decided to use Fpoll for this purpose. My issue mainly lies in getting the poll file to include into the sidebar. I am adding the box by directly modifying index.tpl (If anyone wants to explain how I can make it use its own box template file they are hereby entitled to my firstborn son.) but while I can get the include to seemingly work it is resisting showing the poll itself. Here is the relevant information: Store location: http://www.rackemtees.com/store/ Poll location: http://www.rackemtees.com/store/Fpoll/poll.php Include Code: <div class="boxTitleLeft" align="center"><img src="http://rackemtees.com/store/skins/Rack_Em/styleImages/pollhead.png" height="19" width="156" /></div> <div class="boxContentRight"> <?php include("../Fpoll/poll.php"); ?> </div> Any help is greatly appreciated. Regards, Jon Quote Link to comment Share on other sites More sharing options...
Guest cherryaa Posted September 15, 2008 Share Posted September 15, 2008 This will be very quick and only a little help, but .... You simply can't include php directly in the template files. You can, however, create one of those {} placeholders relatively easily (I may regret saying that!) by calling your include to one of the .inc files and then copying the way Alistair does his assignments. I seem to remember having to add a line to index.php - the one in the root directory - as well. I've only done this once; with luck a CC expert will fill you in a bit more! Hope this gets you started, anyway Edited to add: Or, you could get it running on a page of its own & then ajax it in (or use an iframe). Which is probably what I'd do. Cherry. Quote Link to comment Share on other sites More sharing options...
Guest Jon Bartus Posted September 15, 2008 Share Posted September 15, 2008 This will be very quick and only a little help, but .... You simply can't include php directly in the template files. You can, however, create one of those {} placeholders relatively easily (I may regret saying that!) by calling your include to one of the .inc files and then copying the way Alistair does his assignments. I seem to remember having to add a line to index.php - the one in the root directory - as well. I've only done this once; with luck a CC expert will fill you in a bit more! Hope this gets you started, anyway Edited to add: Or, you could get it running on a page of its own & then ajax it in (or use an iframe). Which is probably what I'd do. Cherry. Yeah, I was hoping not to have to iframe (or ajax) it in... I am disappointed to hear that I can't include it directly, could you perchance assist with creating a {} placeholder as quite honestly this methodology is beyond my experience. Just a simple explanation of how I would do that would more than suffice. Regards, Jon Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 15, 2008 Share Posted September 15, 2008 There are a couple of threads that discuss how to do this at www.cubecartforums.org. Search for "add a box" or "Security Emblem". Quote Link to comment Share on other sites More sharing options...
Guest cherryaa Posted September 16, 2008 Share Posted September 16, 2008 OK, you've probably figured it out by now, but I've just been back over it & am posting here for posterity (mainly in case I forget again!). Caveat: I was not following any instructions and may have made an error. But my simple test works fine on our long-suffering test site. New file: includes/boxes/testInclude.php <?php $newContent = "Included this!"; $box_content=new XTemplate("skins/".$config['skinDir']."/styleTemplates/boxes/testInclude.tpl"); $box_content->assign("NEWSTUFF",$newContent); $box_content->parse("test_inc"); $box_content = $box_content->text("test_inc"); ?> New file: styleTemplates/boxes/testInclude.tpl <!-- BEGIN: test_inc --> <div class="boxTitleLeft">TEST INCLUDE</div> <div class="boxContentLeft"> <span class="txtCopy"> <strong>The file said:</strong> {NEWSTUFF}<br /> </span> </div> <div class="boxFootLeft"> </div> <!-- END: test_inc --> Edited file /index.php, line 180 include("includes/boxes/testInclude.inc.php"); $body->assign("TEST_INC",$box_content); Edited file styleTemplates/global/index.tpl {TEST_INC} {RANDOM_PROD} {POPULAR_PRODUCTS} So now there definitely is a thread on it Cherry. Quote Link to comment Share on other sites More sharing options...
lainyrache Posted October 13, 2008 Share Posted October 13, 2008 Thanks Cherryaa for posting this... I found it really helpful. If anyone is wanting to do this on version 4, I used this guide but with the following amendments... and it all seems to be ok! Instead of adding the include code to /index.php add it to /includes/global/index.inc.php and change to require_once"includes".CC_DS."boxes".CC_DS."testinclude.inc.php"; $body->assign("TEST_INC",$box_content); And in includes/boxes/testInclude.php change line 6 to $box_content=new XTemplate("boxes".CC_DS."testinclude.tpl"); Hope that helps! Rachael 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.