Advertisement:

Author Topic: injecting code on targeted posts?  (Read 465 times)

Offline drewactual

  • Full Member
  • ***
  • Posts: 672
    • College Football Fan Site CFB51
injecting code on targeted posts?
« on: January 14, 2019, 08:33:47 AM »
I've been using the script below in 2.0.15 with much success for the past year or so.  In addition to assigning different functions/items to BOARDS, I'd like to be able to do the same thing with POSTS... is it possible w/o using 'pretty urls' (if the script would even recognize pretty urls for this use anyway)?

Code: [Select]
<?php
if(( isset($_REQUEST['board']) && $_REQUEST['board'] == '1' )  || ( isset($board) && $board == '1' )) { echo '~whatever I'm injecting on board 1~'; }

      elseif(( isset($_REQUEST['
board']) && $_REQUEST['board'] == '2' ) || ( isset($board) && $board == '2' )) {echo '~whatever I'm injecting on board 2~'; }

      elseif(( isset(
$_REQUEST['board']) && $_REQUEST['board'] == '3' ) || ( isset($board) && $board == '3' )) {echo '~whatever I'm injecting on board 3~</div>';}

      elseif(( isset($_REQUEST['
board']) && $_REQUEST['board'] == '4' ) || ( isset($board) && $board == '4' )) { echo '~whatever I'm injecting on board 4~'; }

else {  echo 
'~whatever I'm injecting or not injecting on a non-identified board~'; }
?>

I'd 'like' to use the same injects on messages (from display.index) so the parent(board)/child(message) have the same inject.... I realize this can be done with individual theses for each board, but I'd rather have one file to keep up with instead of having to adjust each 'theme' every time I want to implement a change. 

is this possible?

as always, thanks in advance!!!

Offline Virginiaz

  • Semi-Newbie
  • *
  • Posts: 57
Re: injecting code on targeted posts?
« Reply #1 on: January 19, 2019, 09:29:12 AM »
You could always put some code in Display.php - prepareDisplayContext(), right after

Code: [Select]
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
to check the message ID and add your code to $message['body'] if it matches. Just have it call a function in the file you want to keep everything in.