marklcfc Posted June 16, 2016 Share Posted June 16, 2016 This is regarding this blog post https://invisionpower.com/news/theme-tip-use-html-logic-to-display-content-to-specific-groups-r957/ Do we have any of IF codes as a replacement for these I used since IPB 3. To place code everywhere but topic 69113 <if test="$this->request['t'] != 69113">DISPLAY INFO HERE</if> To place code in topic 69113 specifically <if test="$this->request['t'] == 69113">DISPLAY INFO HERE</if> To place code inside the first post in each topic page <if test="showAds:|:$post['post']['post_count'] % $this->settings['display_max_posts'] == 1">DISPLAY CODE HERE</if> To place code in every topic in forum id 2 <if test="$this->request['f'] == 2">DISPLAY INFO HERE</if> Link to comment Share on other sites More sharing options...
marklcfc Posted June 17, 2016 Author Share Posted June 17, 2016 Does anything exist for placing code after the first post? Link to comment Share on other sites More sharing options...
Colonel_mortis Posted June 18, 2016 Share Posted June 18, 2016 This guide should have the information you want Link to comment Share on other sites More sharing options...
marklcfc Posted July 12, 2016 Author Share Posted July 12, 2016 So is there no code to display everywhere but a certain topic. On 3.4 I did this to prevent code displaying on two topics <if test="$this->request['t'] != 95676 && $this->request['t'] != 95852"> </if> Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 12, 2016 Share Posted July 12, 2016 3 minutes ago, marklcfc said: So is there no code to display everywhere but a certain topic. On 3.4 I did this to prevent code displaying on two topics <if test="$this->request['t'] != 95676 && $this->request['t'] != 95852"> </if> {{if \IPS\Request::i()->id != 1245 || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic'}}<ad here>[{endif}} However, that won't work in the ad slots unless you download the appropriate plugin from the marketplace (advanced adverts or something along those lines) (it does work if you just modify templates though). Link to comment Share on other sites More sharing options...
marklcfc Posted July 12, 2016 Author Share Posted July 12, 2016 Thanks. They are header and footer adverts and I've always placed them in globaltemplate so they display everywhere, so in that cause would I still need app forums and module forums, controller topic? Also if it is two topics I'd like to avoid how should the code be? Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 12, 2016 Share Posted July 12, 2016 33 minutes ago, marklcfc said: Thanks. They are header and footer adverts and I've always placed them in globaltemplate so they display everywhere, so in that cause would I still need app forums and module forums, controller topic? Also if it is two topics I'd like to avoid how should the code be? I added the app/controller/module so that it would only exclude the topic with that ID, and not anything else that happens to have the same ID. I had meant to say that in the post, but appear to have forgotten. To have multiple topics excluded, replace the id check with in_array(\IPS\Request::i()->id, array(1234, 5678, 55423)) (leaving the rest of the code there). Link to comment Share on other sites More sharing options...
marklcfc Posted July 12, 2016 Author Share Posted July 12, 2016 13 minutes ago, Colonel_mortis said: I added the app/controller/module so that it would only exclude the topic with that ID, and not anything else that happens to have the same ID. I had meant to say that in the post, but appear to have forgotten. To have multiple topics excluded, replace the id check with in_array(\IPS\Request::i()->id, array(1234, 5678, 55423)) (leaving the rest of the code there). Just tried it and it works great, thanks alot How would I go about adding the following to it? Would I place it in front of your code and add the extra endif at the end? This is so it only appears to guests too {{if \IPS\Member::loggedIn()->member_id === NULL}} Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 12, 2016 Share Posted July 12, 2016 52 minutes ago, marklcfc said: Just tried it and it works great, thanks alot How would I go about adding the following to it? Would I place it in front of your code and add the extra endif at the end? This is so it only appears to guests too {{if \IPS\Member::loggedIn()->member_id === NULL}} {{if \IPS\Member::loggedIn()->member_id === NULL && ( !in_array(\IPS\Request::i()->id, array(1234, 5678, 55423)) || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic' ) }}<ad here>{{endif}} Link to comment Share on other sites More sharing options...
marklcfc Posted July 12, 2016 Author Share Posted July 12, 2016 That works apart from it shows to just the topics in the array, I would like to show to all but those in the array Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 12, 2016 Share Posted July 12, 2016 Just now, marklcfc said: That works apart from it shows to just the topics in the array, I would like to show to all but those in the array Oops. Add an ! before the in_array (I've updated the code in my post). Link to comment Share on other sites More sharing options...
marklcfc Posted July 18, 2016 Author Share Posted July 18, 2016 @Colonel_mortis say I'm using this {{if \IPS\Member::loggedIn()->member_id === NULL && ( !in_array(\IPS\Request::i()->id, array(95676, 95852)) || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic' ) }} what do I use to show to all members instead of guests, but keeping the not in topics part? I tried removing the first part but it wasn't having it Link to comment Share on other sites More sharing options...
marklcfc Posted July 18, 2016 Author Share Posted July 18, 2016 Also is there any code to show after 2nd post in each topic page Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 19, 2016 Share Posted July 19, 2016 On 18/07/2016 at 4:41 AM, marklcfc said: @Colonel_mortis say I'm using this {{if \IPS\Member::loggedIn()->member_id === NULL && ( !in_array(\IPS\Request::i()->id, array(95676, 95852)) || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic' ) }} what do I use to show to all members instead of guests, but keeping the not in topics part? I tried removing the first part but it wasn't having it You want something like {{if !in_array(\IPS\Request::i()->id, array(95676, 95852)) || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic' }} (getting rid of the member ID check and the && (as well as (), but they can be left)). On 18/07/2016 at 1:55 PM, marklcfc said: Also is there any code to show after 2nd post in each topic page I'm not 100% sure, but I think you would have to make a theme hook or edit the template to achieve that. Link to comment Share on other sites More sharing options...
marklcfc Posted July 21, 2016 Author Share Posted July 21, 2016 How to avoid showing on registration page? Does such code exist? Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 25, 2016 Share Posted July 25, 2016 On 22/07/2016 at 0:20 AM, marklcfc said: How to avoid showing on registration page? Does such code exist? {{if (!in_array(\IPS\Request::i()->id, array(95676, 95852)) || \IPS\Request::i()->app != 'forums' || \IPS\Request::i()->module != 'forums' || \IPS\Request::i()->controller != 'topic') && (\IPS\Request::i()->app != 'core' || \IPS\Request::i()->module != 'system' || \IPS\Request::i()->controller != 'register') }} Link to comment Share on other sites More sharing options...
marklcfc Posted July 25, 2016 Author Share Posted July 25, 2016 Thanks. Any idea if all these if instances slow a website up? Link to comment Share on other sites More sharing options...
Colonel_mortis Posted July 25, 2016 Share Posted July 25, 2016 45 minutes ago, marklcfc said: Thanks. Any idea if all these if instances slow a website up? They wouldn't make a difference, no (well, it would slow it down by nanoseconds, but not by anything remotely measurable). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.