Guest Posted June 16, 2007 Share Posted June 16, 2007 Hi all, searching in the forums I found a way to add custom boxes with my own content as in this thread I followed all instruccions, double checked grammar and spelling but my php content keeps rendering on top of my page and not in the content box!!! Im lost a what to do since I been trying to solve this for a long time now... here is my code in Index.php include("includes/boxes/news.inc.php"); $body->assign("news",$box_content); in news.inc.php <?php include("include_news.php"); $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/news.tpl"); $box_content->parse("news"); $box_content = $box_content->text("news"); ?> and in news.tpl <!-- BEGIN: news --> <!-- END: news --> I tried NEWS doing UPPER CASE and lower case but that didnt work either what am I doing grong??? thanks in advance :) Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2007 Share Posted June 16, 2007 You need to assign your content to a variable. Example: $box_content->assign("LANG_SALE_ITEMS_TITLE",$lang['front']['boxes']['sale_items']); This assigns content to the variable {LANG_SALE_ITEMS_TITLE}, which would be placed into the template. Just study the default CubeCart files for examples of how it's done. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2007 Share Posted June 16, 2007 Thanks for the quick reply^^ I did check how others boxes are done... but they are too complex for me to fully understand my content is pulled from include("include_news.php"); how do I get it INSIDE the box? I know is silly but I tried $box_content->parse("include_news.php"); of course it didnt work it just keeps rendering on top of the page and not in the box {news} (I tried NEWS also XD) position T_T Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2007 Share Posted June 16, 2007 Try something like: $content = include("include_news.php"); $box_content->assign("NEWS", $content); $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/news.tpl"); $box_content->parse("news"); $box_content = $box_content->text("news"); The first line is where the custom content gets assigned to a variable rather than spit out to the screen above everything else. There was a post a while back that used the following code: $file = file_get_contents("http://www.mysite.com/include_news.php"); $box_content->assign("NEWS", $file); You might try that too if the above doesn't work. In your template, place {NEWS} where you want that content to show up. <!-- BEGIN: news --> {NEWS} <!-- END: news --> Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2007 Share Posted June 16, 2007 My curiousity got the better of me, so I did some research into capturing php output to a variable, and I think I found the 'proper' way to do it. (Webpage where I found it.) ob_start(); // start buffer include ("file-to-include.php"); $content = ob_get_contents(); // assign buffer contents to variable ob_end_clean(); // end buffer and remove buffer contents echo $content; For use in CubeCart, this would translate as: ob_start(); // start buffer include ("include_news.php"); $content = ob_get_contents(); // assign buffer contents to variable ob_end_clean(); // end buffer and remove buffer contents $box_content->assign("NEWS", $content); $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/news.tpl"); $box_content->parse("news"); $box_content = $box_content->text("news"); Quote Link to comment Share on other sites More sharing options...
markscarts Posted June 16, 2007 Share Posted June 16, 2007 Also (to myka) that is a very old thread you found, with very good GENERAL information, there are others more pertinent to your specific problem, http://www.cubecart.com/site/forums/index....st&p=123381 Quote Link to comment Share on other sites More sharing options...
Guest dtmswebmaster Posted June 18, 2007 Share Posted June 18, 2007 Hi all, searching in the forums I found a way to add custom boxes with my own content as in this thread I followed all instruccions, double checked grammar and spelling but my php content keeps rendering on top of my page and not in the content box!!! Im lost a what to do since I been trying to solve this for a long time now... here is my code in Index.php include("includes/boxes/news.inc.php"); $body->assign("news",$box_content); in news.inc.php <?php include("include_news.php"); $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/news.tpl"); $box_content->parse("news"); $box_content = $box_content->text("news"); ?> and in news.tpl <!-- BEGIN: news --> <!-- END: news --> I tried NEWS doing UPPER CASE and lower case but that didnt work either what am I doing grong??? thanks in advance Ok.. the only thing I see wrong here, is that you haven't called it up in the /skins/Your_Skin/styleTemplates/global/index.tpl file. In this file, you can add {news} to "link" it all and make it work. Also try moving into the news.tpl file for it to add it within the box. ... I hope this helps ya. :Dinclude("include_news.php"); Quote Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2007 Share Posted June 18, 2007 With CubeCart's template system, it's not possible to place PHP code into the TPL files. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2007 Share Posted June 18, 2007 AlanT is right, includes do not work inside tpls (I tried ) Markscarts THAT DID IT! thank you very much, and thanks everyone for being so supportive ^^ :) Quote Link to comment Share on other sites More sharing options...
markscarts Posted June 18, 2007 Share Posted June 18, 2007 No problem, AGTH BTW, I tried adding a news blog for one of my customers and kept having the same problem; it was nice to see that a member here found the way to code it in that post I gave above Very useful info, IMO For any other interested parties, this can usually be done without all the complication like this: $file = file_get_contents("http://www.mysite.com/include_news.php"); $body->assign("NEWS", $file); And then call it in index.tpl using {NEWS} Is that how you did it, myka? Quote Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2007 Share Posted June 18, 2007 Yep ^^ that's how =P My site is getting really cool with all the stuff I learn in the forums, thanks to everybody, this is a great comunity BTW there's another way to do it... its with iframes, very usefull, I added two Iframes to my index.tpl. In one iframe I got loaded the php stuff (they are news) and when clicked, the news get loaded in the main frame, looks pretty cool two. 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.