SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: pnreddy on February 14, 2011, 12:55:43 AM

Title: A HTML/PHP SP Block which looks similar to a post
Post by: pnreddy on February 14, 2011, 12:55:43 AM
Hello,

Can anyone help me in creating a HTML/PHP block which looks similar to a post.

The purpose of the block is to mimick a post in which I want to add google adsense and to put the block on the top of all posts. The theory says it increases adsense click through rate.

Many of the Vbulletin forums have the option to do so. I have seen one SMF having that implemented and I learned that they used a SP block above all posts which had HTML made to mimick a post.

Any help will be greatly appreciated.

pnreddy

Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: AngelinaBelle on February 15, 2011, 11:20:32 AM
Easy solution:
1) Create a post that contains the ad-sense HTML
2) Create a custom php block
3) In that block, call ssi_fetchPosts (using the post's message id), and let it show the post.
 
Slightly more involved solution:
1) Create a custom block
2) Copy some HTML from a page that displays some post, and paste it into your block
3) Embed your AD-sense HTML in the middle of that post, instead of the post contents.
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: pnreddy on February 16, 2011, 01:06:32 PM
Quote
Slightly more involved solution:
1) Create a custom block
2) Copy some HTML from a page that displays some post, and paste it into your block
3) Embed your AD-sense HTML in the middle of that post, instead of the post contents.

I tried to do this much earlier before asking help here. I copied html and posted in Custom block(html), however, the block looks like a tower, but not as a post and skews entire page..I am unsure if I did correctly..

Quote
Easy solution:
1) Create a post that contains the ad-sense HTML
2) Create a custom php block
3) In that block, call ssi_fetchPosts (using the post's message id), and let it show the post

I think I will try this one.. But, can you please help me what code I should exactly add?

I am sorry if this sounds very silly, But I am a php noob!

Thanks,
pnr
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: AngelinaBelle on February 16, 2011, 02:42:46 PM
I will help. First, see in ssi.php that function. see what information it wants.
 
Now, find a message you want to use. Find its message ID.
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: pnreddy on February 17, 2011, 11:00:11 AM
Its all geek to me :dead:

Can you help me with the html way?
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: AngelinaBelle on February 17, 2011, 11:03:41 AM
Over here in customization, it is all geek, all the time.
So get your geek on and get started :)
 
Find this posts's message ID.
Look at a post. see how the post's title is actually a link.
Hover over the link, and see how the URL of the link shows up in the status bar at the bottom of your browser. See the part of the URL that says msg and has a number? that's telling you the message ID.
 
Tell me the message ID of this message. Then you'll know you've figured it out.
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: pnreddy on February 17, 2011, 11:09:50 AM
Thanks, I would like to use the msg id 923 for using in the block
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: AngelinaBelle on February 17, 2011, 11:15:29 AM
OK. I think you get that, but I cannot check. The id of my previous message (the one asking for the id) is 43166. If you get that, then you get it all.
 
Now, look in SSI.php for the function you'll want to call. I gave you the name of that function above.
Copy the proper line out of SSI.php and paste it into your next post. put  tags around it to make it look like code.
See how it lists the parameters you want?
Now, use that information to show how you think you might actually write a line of php code to call that function. It is OK to "cheat" and look at some actual php to see how other code writers have actually called other functions.
 
Go ahead.
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: pnreddy on February 17, 2011, 11:39:57 AM
The below code is what I see in SSI.PHP
Quote
// Fetch a post with a particular ID. By default will only show if you have permission to the see the board in question - this can be overriden.
function ssi_fetchPosts($post_ids, $override_permissions = false, $output_method = 'echo')
{
   global $user_info, $modSettings;

   // Allow the user to request more than one - why not?
   $post_ids = is_array($post_ids) ? $post_ids : array($post_ids);

   // Restrict the posts required...
   $query_where = '
      m.id_msg IN ({array_int:message_list})' . ($override_permissions ? '' : '
         AND {query_wanna_see_board}') . ($modSettings['postmod_active'] ? '
         AND m.approved = {int:is_approved}' : '');
   $query_where_params = array(
      'message_list' => $post_ids,
      'is_approved' => 1,
   );

   // Then make the query and dump the data.
   return ssi_queryPosts($query_where, $query_where_params, '', 'm.id_msg DESC', $output_method);
}

Now, what should I modify in the code?
Title: Re: A HTML/PHP SP Block which looks similar to a post
Post by: AngelinaBelle on February 17, 2011, 12:23:06 PM
All you need is to see the function definition.
You will not need to modify any of this code
Code: [Select]
function ssi_fetchPosts($post_ids, $override_permissions = false, $output_method = 'echo')
Can you see there, where you have to give it a $post_id? That's the id of your one message.
Code: [Select]
ssi_fetchPosts(923);
Put that in your php block. It won't look EXACTLY the same as it looks on the forum, but it will be pretty close.
There's your introduction to php.
It's not that hard, really. http://w3schools.com/php (http://w3schools.com/php)
SimplePortal 2.3.8 © 2008-2024, SimplePortal