Guest deltakid Posted October 30, 2005 Share Posted October 30, 2005 I would like to create .tpl files and keep the code of my cubecart as clean as it is right now. For example if I want to add one of these .tpl files in my index.tpl i would like to do it like it is done with {PAGE_CONTENT} or {CATEGORIES}. Can anyone give me a quick walkthrough how i would go ahead and where i have to "declare" which variable means which .tpl file ({CATEGORIES} -> boxes/categories.tpl) ******* edit: looked around and found this which answers my questions: written by convict You have to write your own box tepmlate file, appropriate php file, additional LANG variable(s). I suppose, you dont know anything about PHP TEMPLATES. Principle in practice ----------------------- Have look to includes/boxes folder. Lot of boxes php files here. Appropriate templates folder is skins/<-your favorite skin->/styleTemplates/boxes. How the whole parsing works? ---------------------------------- Php files for boxes are included into index.php like thisinclude("includes/boxes/searchForm.inc.php"); $body->assign("SEARCH_FORM",$box_content); Just have look at SEARCH_FORM in code above, open the main index template skins/<-your favorite skin->/styleTemplates/global/index.tpl and search for SEARCH_FORM. Here is {SEARCH_FORM} - template variable parsed by $body->assign("SEARCH_FORM",$box_content) command . It means, that whole code for this box just in this position resides. And what about box code?. Open skins/<-your favorite skin->/styleTemplates/boxes/searchForm.tpl. This is plain html code, except template variables like {LANG_SEARCH_FOR}. This variable is parsed in appropriate php for searchForm.tpl - includes/boxes/searchForm.inc.php just open it and yes, we are right $box_content = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/searchForm.tpl"); Command like $box_content->assign("LANG_GO",$lang['front']['boxes']['go']); does already used language assignation for {LANG_GO} and $lang['front']['boxes']['go'] is language variable defined within lang.inc.php. Finally, all of our variables, which are needed for template must be parsed. $box_content->parse("search_form"); $box_content = $box_content->text("search_form");As you see, $box_content contains search box html code. OK, thats all. You are welocome to PM me, if you have any problem. Quote Link to comment Share on other sites More sharing options...
Guest samsoft24 Posted September 11, 2009 Share Posted September 11, 2009 I would like to create .tpl files and keep the code of my cubecart as clean as it is right now. For example if I want to add one of these .tpl files in my index.tpl i would like to do it like it is done with {PAGE_CONTENT} or {CATEGORIES}. Can anyone give me a quick walkthrough how i would go ahead and where i have to "declare" which variable means which .tpl file ({CATEGORIES} -> boxes/categories.tpl) ******* edit: looked around and found this which answers my questions: written by convict You have to write your own box tepmlate file, appropriate php file, additional LANG variable(s). I suppose, you dont know anything about PHP TEMPLATES. Principle in practice ----------------------- Have look to includes/boxes folder. Lot of boxes php files here. Appropriate templates folder is skins/<-your favorite skin->/styleTemplates/boxes. How the whole parsing works? ---------------------------------- Php files for boxes are included into index.php like thisinclude("includes/boxes/searchForm.inc.php"); $body->assign("SEARCH_FORM",$box_content); Just have look at SEARCH_FORM in code above, open the main index template skins/<-your favorite skin->/styleTemplates/global/index.tpl and search for SEARCH_FORM. Here is {SEARCH_FORM} - template variable parsed by $body->assign("SEARCH_FORM",$box_content) command . It means, that whole code for this box just in this position resides. And what about box code?. Open skins/<-your favorite skin->/styleTemplates/boxes/searchForm.tpl. This is plain html code, except template variables like {LANG_SEARCH_FOR}. This variable is parsed in appropriate php for searchForm.tpl - includes/boxes/searchForm.inc.php just open it and yes, we are right $box_content = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/searchForm.tpl"); Command like $box_content->assign("LANG_GO",$lang['front']['boxes']['go']); does already used language assignation for {LANG_GO} and $lang['front']['boxes']['go'] is language variable defined within lang.inc.php. Finally, all of our variables, which are needed for template must be parsed. $box_content->parse("search_form"); $box_content = $box_content->text("search_form");As you see, $box_content contains search box html code. OK, thats all. You are welocome to PM me, if you have any problem. Thanks for the detailed explanation. I am using CC4 and would like to add new boxes using templates. Can you please guide me on how I should go about creating templates? Especially the code that you've mentioned above, I am not sure which index.php it should go to. Quote Link to comment Share on other sites More sharing options...
Guest Posted September 21, 2009 Share Posted September 21, 2009 Very useful, thanks! 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.