SimplePortal

Support => English Support => Topic started by: akshtsaklani7 on October 07, 2014, 04:46:58 AM

Title: What block is it?
Post by: akshtsaklani7 on October 07, 2014, 04:46:58 AM
http://www.wpdota.com/

On this website, What block is being used to display the news? and if it is board news block, how can I modify board news block on my website to look this way? like, the first image in the topic appearing on the left, being resized to a particular size?
Title: Re: What block is it?
Post by: Burke Knight on October 07, 2014, 06:51:48 AM
Looks like standard News block.
They did BBC in the news setting in SMF to do that.

Or...

They just made a custom BBC block for their news.
Title: Re: What block is it?
Post by: andy on October 07, 2014, 11:16:03 AM
I havent seen the SMF one but I looked for similar things when making my portal. It looks like one of many javascript or php image rotators. You can find on the internet if you search.

I decided on a very simple page reload/new image on my site. No fancy stuff...

It uses rotate.php for an image folder, so no linking to topics. That can be found though. Depends how much work you want to do.

There are other topics on Simple Portal about image rotators or image/news display. Also scripts on other SMF portal site... I wont mention.
Google is your God - ask it.

Title: Re: What block is it?
Post by: Burke Knight on October 07, 2014, 11:51:47 AM
I thought the OP was talking about the block titled: News
At the right side.

However, I also like the center one, which I guess is just a custom HTML or PHP block with custom code.

Incidentally, SMF 2.1 will have a news fader that is done as a slider. ;)
Title: Re: What block is it?
Post by: [SiNaN] on October 11, 2014, 06:12:00 AM
In order to extract the first image from the post, you can something as follows:

PortalBlocks.php

Code: (Find) [Select]
// Only place an ellipsis if the body has been shortened.
Code: (Replace) [Select]
if (preg_match('~<img src="([^"]+)"[^>]*bbc_img[^"]*" />~', $row['body'], $matches))
{
$row['body'] = preg_replace('~^<br />(<br />)?~', '', preg_replace('~<img[^>]*bbc_img[^"]*" />~', '', $row['body'], 1));
$row['body'] = '<img src="' . $matches[1] . '" style="float: left; max-width: 200px; margin-right: 1em;" alt="" />' . $row['body'];
}

// Only place an ellipsis if the body has been shortened.
Title: Re: What block is it?
Post by: akshtsaklani7 on October 18, 2014, 01:45:32 AM
Alright, the code above works only if the image is inserted within the character limit of the preview. Can it be like it displays the image no matter if its at the end of the topic without considering the character limit? Also can we somehow avoid the text formatting in the preview of the news board?
Title: Re: What block is it?
Post by: [SiNaN] on October 19, 2014, 03:29:32 PM
I can do pretty much anything but I hope that was all you wanted as I won't be able to work on this request any more.

For the first:

Code: (Find) [Select]
$limited = false;
Code: (Replace) [Select]
$image = '';
if (preg_match('~\[img\]([^\[]+?)\[/img\]~', $row['body'], $matches))
{
$image = '<img src="' . $matches[1] . '" style="float: left; max-width: 200px; margin-right: 1em;" alt="" />';
$row['body'] = preg_replace('~\[img\]([^\[]+?)\[/img\]~', '', $row['body'], 1);
}

$limited = false;

Code: (Find) [Select]
// Only place an ellipsis if the body has been shortened.
Code: (Replace) [Select]
$row['body'] = strip_tags($row['body']);
if (!empty($image))
$row['body'] = $image . $row['body'];

// Only place an ellipsis if the body has been shortened.

If you want to keep some formatting tags, you can get help from the following page:

http://php.net/strip_tags
Title: Re: What block is it?
Post by: akshtsaklani7 on October 20, 2014, 12:07:57 AM
Thanks a lot sir, The article and the code, both helped to achieve exactly what I needed.
Title: Re: What block is it?
Post by: [SiNaN] on October 20, 2014, 03:15:35 AM
You're welcome. ;)
SimplePortal 2.3.8 © 2008-2024, SimplePortal