SimplePortal
Support => English Support => Topic started 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?
-
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.
-
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.
-
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. ;)
-
In order to extract the first image from the post, you can something as follows:
PortalBlocks.php
// Only place an ellipsis if the body has been shortened.
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.
-
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?
-
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:
$limited = false;
$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;
// Only place an ellipsis if the body has been shortened.
$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
-
Thanks a lot sir, The article and the code, both helped to achieve exactly what I needed.
-
You're welcome. ;)