• Welcome to Simple Machines Community Forum. Please login or sign up.
October 23, 2021, 08:33:49 AM

News:

SMF 2.1 RC4 has been released! Try it out and help us test! :) Read more.


injecting code on targeted posts?

Started by drewactual, January 14, 2019, 08:33:47 AM

Previous topic - Next topic

drewactual

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)?

<?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!!!

vii

You could always put some code in Display.php - prepareDisplayContext(), right after

$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.

Advertisement: