MyBB Community Forums

Full Version: Placing ads in the Postbit Content
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is it possible to place ads in between the contents of post as I have shown in the below pics:

Right now I am showing ads with Yaldaram's My Advisement in post like this:


[Image: postbit1.jpg]

So now if I want to change the above ad place to as indiacted in the below picture, What I need to do.

[Image: postbit2.jpg]
post message can start with advertisement or can end with advertisement. but advt can not be placed easily
in between the post content. may be xThreads experts can provide better guidance - let us wait Smile

Edit: advertisement can be placed in a div element and its position may be adjusted with css style - not sure if this works!
(2013-07-26, 11:05 AM).m. Wrote: [ -> ]post message can start with advertisement or can end with advertisement. but advt can not be placed easily
in between the post content. may be xThreads experts can provide better guidance - let us wait Smile

Edit: advertisement can be placed in a div element and its position may be adjusted with css style - not sure if this works!

Yes ie the same hope I had with the css!!! Let's see I can go forward from here. Also any help will be appreciated.
You can, maybe, use some PHP to read the message string & when it reaches to the length of MESSAGE/2 then Append the ad code to it, do you get my point?
Yes bro, But I was thinking if I do like that, it my affect the performance of the website.
I know this is possible, but why do this. Its extremly annoying to your users.
Not really, that might not affect your performance too much.

You can use:

$adcode = ""; //some valid adcode
$halfmessagelen = (strlen($message))/2;
for ($i = $halfmessagelen; $i>=0; $i++)
 {
  if ($message[$i] == "\n")  // Search for a break
   {
     $message[$i] = $message . $adcode;
     break; // Stop the de-loop
   }
 }

I think, that code should work.
(2013-07-27, 03:37 PM)Angel Caquias Wrote: [ -> ]I know this is possible, but why do this. Its extremly annoying to your users.

I own a Job board, where there is no activity, except that all users just come to site to see the jobs, apply to them and they will leave. So as there's no much of activity apart from the staff, so I am opting this.

(2013-07-27, 04:06 PM)Cedric Wrote: [ -> ]Not really, that might not affect your performance too much.

You can use:

$adcode = ""; //some valid adcode
$halfmessagelen = (strlen($message))/2;
for ($i = $halfmessagelen; $i>=0; $i++)
 {
  if ($message[$i] == "\n")  // Search for a break
   {
     $message[$i] = $message . $adcode;
     break; // Stop the de-loop
   }
 }

I think, that code should work.

Thanks bro, I will test this once and have check on the website performance.
Hi all, after some work, I am able to insert the code, where I wanted to with a db query.

Which is as follows:

					    $query = $db->query ("SELECT t.tid, p.subject, p.message 
 FROM mybb_threads t, mybb_posts p 
where t.tid=".$thread['tid']." and t.firstpost=p.pid");
  
                        $postq = $db->fetch_array($query);  
                        $msg = $postq['message'];
                         					    
                        $pieces = explode("Job Description", $msg);
                        $res = $pieces[0]."\n\n"."Some code here"."\n\n\n"."Job Description".$pieces[1]; 
                        $post['message'] = $res;

But after this, when I try to access the thread, the inserted code is there, but the complete bbcode didn't converted to html as you see in below picture.

[Image: Insert_in_content_of_post.png]

I know bbcode brushing is happening before my function call, so what I have to do it here.
May be you should use:


// Set up the message parser if it doesn't already exist.
if(!$parser)
	{
		require_once MYBB_ROOT."inc/class_parser.php";
		$parser = new postParser;
	}

// Set up Parser Options

$parser_options['allow_html'] = $forum['allowhtml'];
$parser_options['allow_mycode'] = $forum['allowmycode'];
$parser_options['allow_smilies'] = $forum['allowsmilies'];			$parser_options['allow_imgcode'] = $forum['allowimgcode'];
$parser_options['allow_videocode'] = $forum['allowvideocode'];
$parser_options['filter_badwords'] = 1;

$post['message'] = $parser->parse_message($post['message'], $parser_options);

Smile
Pages: 1 2