Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt November 11, 2024
The Geek Posted March 11, 2010 Posted March 11, 2010 I cannot get my head around adding and editing an apps template. Not at all.My system is in_dev mode so I am ass/u/me/ng that the templates being used are in cache/master_skinHowever going into Look and Feel, I can't edit or add templates to the master_skinFor giggles I created the template in the default IPS style. Its there, but predictably not in the master styleI recache master style and that seems to create my template in the master style, but doesn't have any of the code in it.I manually create the damn template in the master_skin folder but it doesn't get called. Also notice naming convention doesn't match the other styles.Have looked through a few articles in the resource area and haven't had much luck.I am just wanting to add a damn template, not get into MI-5. Who do I have to kill? Love in advance.
Peter F. Posted March 11, 2010 Posted March 11, 2010 Templates you are creating go into /cache/skin_cache/master_skin/ You then edit the php files directly as opposed to in the ACP. edited to fix small mistake
The Geek Posted March 11, 2010 Author Posted March 11, 2010 Sorry, that was a typo. It is in master_skin. the classes are structured differently there. Is this correct? Obviously this has no functions (yet): class skin_global_1 extends output { }
Peter F. Posted March 11, 2010 Posted March 11, 2010 Also this article may be of use: http://community.invisionpower.com/resources/official.html?record=156 Specifically the {appname}_*_templates.xml section of it
Peter F. Posted March 11, 2010 Posted March 11, 2010 Sorry, that was a typo. It is in master_skin. the classes are structured differently there. Is this correct? Obviously this has no functions (yet): class skin_global_1 extends output { } Yep they are. For example in the awards app I created I created the skin_awards template. I created this template in a file called skin_awards.php Here is an example of one of the templates from the file:<?php class skin_global_1 extends output { //=========================================================================== // Name: Awards //=========================================================================== function Awards($content) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <div id="list_awards" class='overflow'> <h3 class='bar bigboldaward' id='list_awards'> <table> <tr> <td>{$this->lang->words['awards_public_title']}</td> </tr> <tr> <td style='width: 12.5%' class="awardshead">{$this->lang->words['awards_public_ha']}</td> <td style='width: 50%' class="awardshead">{$this->lang->words['awards_public_hd']}</td> <td style='width: 37.5%' class="awardshead">{$this->lang->words['awards_public_hm']}</td> </tr> </table> </h3> <div class="general_box alt"> <ol id='forum_table'> {$content} </ol> </div> </div> EOF; //--endhtml--// return $IPBHTML; } } ?> EDIT: that can then be called using the call: $this->registry->getClass('output')->getTemplate('awards')->Awards($content);
The Geek Posted March 11, 2010 Author Posted March 11, 2010 Thanks... still not working and not exactly sure why. Going to try it afresh tomorrow. I appreciate your help peaderfi!
Razasharp Posted March 11, 2010 Posted March 11, 2010 I gave up on in_dev mode, after my latest attempt seemed to have done a disappearing trick on the scroll bars. However fyi: CSS to be edited in the files in: public/style_css/Templates must be edited in the files in: skin_cache/master_skinWhen in IN_DEV mode the skin you're editing is the master skin, which is separate to the normal skinning templates. You can then import your changes to the IP.Board (or other skins using the masterMap file) skin if you want to, which is what we do during development. So it is the IP.Board skin, but it isn't, if that makes sense =) The template files are indeed cache/skin_cache/master_skin and CSS files are public/style_css/master_css In the end I thought as this is my first skin attempt I'd probably be better off getting used to doing things the normal way first. In_dev mode does things differently in a number of areas (such as templates are 'grouped' together in files as opposed to just one file per template - changes you make in ACP L&F don't get carried across, etc).
Peter F. Posted March 11, 2010 Posted March 11, 2010 If you want it to display you would use something like this:$content = 'options and stuff you wanna use'; $this->html = $this->registry->getClass('output')->getTemplate('awards')->Awards($content); $this->registry->output->addContent( $this->html ); $this->registry->output->sendOutput();
The Geek Posted March 11, 2010 Author Posted March 11, 2010 I deleted the file in master_skin and recached from the default style. That gets me closer as it looks like it is finally loading the class when I step through my debugger, but for whatever reason my function isn't returning anything. Not even an error. Clearly I have borked something up along the way - just frustrating as I have now spent a good couple hours on something that SHOULD be quick and simple. Will try tomorrow with a totally new skin. Thanks again for your help :)
bfarber Posted March 11, 2010 Posted March 11, 2010 I just recently setup a board for IN_DEV a day or two ago. Here are the steps I took.... 1) Install IPB as normal (I did a fresh install to a new folder) 2) Open conf_global.php and change the constant IN_DEV to 1. 3) Go into the ACP, go to Look and Feel, Template Tools. Click the tool labeled "Create Master PHP Templates Directory". 4) In FTP/Explorer, copy cache/lang_cache/1/ to cache/lang_cache/master_lang/ 5) In FTP/Explorer, copy public/style_css/1/ to public/style_css/master_css/ That's it. From there, I can add new skin files in master_skin folder (which was created by step 3), or new templates to existing files in this folder, and then I run the tool under Template tools "Rebuild Master HTML From PHP Caches" to import it. Note that you will get an error when you run this tool if you haven't created the xml and lofi skin folders, but you can ignore that error (it's an exception NO_SUCH_DIR or something similar).
The Geek Posted March 12, 2010 Author Posted March 12, 2010 Something is wrong here. Maybe its a windows bug.. but there is a bug none the less. I even started with scratch adding a new skin to master_skin. Pretty simple stuff: master_skin/skin_mudd.php class skin_global_1 extends output { function hiThere() { return "<!-- YO MAMA -->"; } }?> <?php And call it in a template hook: class muddCookie { public $registry; public function __construct() { $this->registry = ipsRegistry::instance(); } public function getOutput() { $return = $this->registry->getClass('output')->getTemplate('mudd')->hiThere(); return $return; } } ?> <?php I can trace execution and can verify that skin_mudd is loaded and returned from publicOutput->getTemplate. In fact, If I change the method from hiThere to HoThere, I get a "unknown method" error. HOWEVER... I cannot step through the skin_mudd.php code Nor does it return "<!-- YO MAMA -->". It doesn't even show any errors. It just silently moves on. So its either a bug somewhere or I am missing something totally obvious. Happy to do a webex for IPS staff if needed.
Peter F. Posted March 12, 2010 Posted March 12, 2010 What template is the template hook hooking into? and is the template it is hooking into being displayed? For example a hook I have made hooks into the profile template at a particular point, it then calls a template I have created and inserts it into the profile template at the point the hook is running at.
The Geek Posted March 12, 2010 Author Posted March 12, 2010 Hey peaderfi, The hook is being called. I can step through the code. Heck, if I cann a different function to hiThere it will crash with "unknown method". So the template hook is fine. Odd stuff.
bfarber Posted March 12, 2010 Posted March 12, 2010 I'm 99% sure the template engine parser requires the comment to be there for the function. Parsing the skin file is tricky business. Try changing <?php class skin_global_1 extends output { function hiThere() { return "<!-- YO MAMA -->"; } }?> to <?php class skin_global_1 extends output { //=========================================================================== // <ips:entry_email_form:desc::trigger:> //=========================================================================== function hiThere() { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <!-- YO MAMA --> EOF; //--endhtml--// return $IPBHTML; } } ?> As I said, I'm pretty sure the skin file MUST be formatted exactly as you see it formatted for the other skin files (//--starthtml--// and //--endhtml--// comments for instance).
The Geek Posted March 12, 2010 Author Posted March 12, 2010 right. I didn't realise that and don't recall seeing that emphasised anywhere. Regardless, it worked. Thanks a lot!
Peter F. Posted March 12, 2010 Posted March 12, 2010 I'm 99% sure the template engine parser requires the comment to be there for the function. Parsing the skin file is tricky business. Try changing <?php class skin_global_1 extends output { function hiThere() { return "<!-- YO MAMA -->"; } }?> to <?php class skin_global_1 extends output { //=========================================================================== // <ips:entry_email_form:desc::trigger:> //=========================================================================== function hiThere() { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <!-- YO MAMA --> EOF; //--endhtml--// return $IPBHTML; } } ?> As I said, I'm pretty sure the skin file MUST be formatted exactly as you see it formatted for the other skin files (//--starthtml--// and //--endhtml--// comments for instance). Looking through the classTemplateEngine (line 317) you do need the $IPBHTML, however it doesn't *need* the comment from what I can see: //=========================================================================== // <ips:entry_email_form:desc::trigger:> //=========================================================================== instead it detects on the function hiThere() { line.
Alex Posted March 12, 2010 Posted March 12, 2010 Yeah, for clarification when I've been doing some templates, it looks for the $IPBHTML parts.$IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF EOF; //--endhtml--// return $IPBHTML;
The Geek Posted March 12, 2010 Author Posted March 12, 2010 Thanks Alex... Where would any logic go? i.e. code that would normally by in <php> tags?
Rikki Posted March 12, 2010 Posted March 12, 2010 The skin files you write in in_dev mode are uncompiled (compiled at run-time), so you enter code just like you would in the ACP. That means you can use <if>, <foreach> and <php> tags as normal :) You shouldn't end the <<<EOF inside skin bits you're editing - the IPB skin system won't understand that I don't think. You have to treat it as a continuous block of HTML, and do your programming inside it using <php> tags.
The Geek Posted March 12, 2010 Author Posted March 12, 2010 Thanks Rikki, based on that, I tried:&fk=<php>md5(IPS_UNIX_TIME_NOW);</php>" in one of the templates... it came out as: &fk=" Shouldn't that have worked?
Lewis P Posted March 12, 2010 Posted March 12, 2010 &fk=<php>$timeNow = md5(IPS_UNIX_TIME_NOW); </php>{$timeNow}" Should work. You might want to move the <php></php> bit outside the "" tags. :)
Peter F. Posted March 12, 2010 Posted March 12, 2010 You should use&fk={parse expression="md5(IPS_UNIX_TIME_NOW);"} EDIT: Parse Tags are particularly useful for this sort of stuff. The <php> Template Logic tags should really only be used if you are doing more in depth php manipulations...
Josh Posted March 12, 2010 Posted March 12, 2010 Thanks Rikki, based on that, I tried:&fk=<php>md5(IPS_UNIX_TIME_NOW);</php>" in one of the templates... it came out as: &fk=" Shouldn't that have worked? <php> tags are not parsed in place, they're parsed at the start of the function. So any output you need from that, needs to be assigned to a variable and then that can be used where you want the output.
The Geek Posted March 12, 2010 Author Posted March 12, 2010 Thanks Lewis - it isn't working (and that is where I need it) :) here is the file:<?php class skin_global_1 extends output { function getFlashCookie( $fk ) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <object type=\"application/x-shockwave-flash\" data=\"{$this->settings['board_url']}/public/mudd.swf\" width=\"1px\" height=\"1px\"> <param name="movie" value=\"{$this->settings['board_url']}/public/mudd.swf\" /> <param name="FlashVars" value="memberid={$this->memberData['member_id']}&hash={$this->member->session_id}&fk=<php>md5(IPS_UNIX_TIME_NOW);</php>" /> </object> EOF; //--endhtml--// return $IPBHTML; } } ?> I was just passing the md5 as a parameter, but would like to get my head around why this isn't working.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.