SimplePortal
Support => English Support => Topic started by: langel on September 21, 2014, 08:12:54 PM
-
Hi buddies :)
Today I come with a request, what happens is I want to create a special block and part of its contents is to show the first image of the topic.
Only the first published image of a topic, whether if posted at the beginning or the end of the topic, just extract that image and display it in a block on the portal.
I hope I've given to understand, search the forum but found nothing
Thanks!!
-
any help here? :(
-
You can use something like the following in a Custom PHP block:
$posts = ssi_boardNews(null, null, null, null, 'return');
foreach ($posts as $post)
if (preg_match('~<img src="([^"]+)"[^>]*bbc_img[^"]*" />~', $post['body'], $matches))
echo '<img src="', $matches[1], '" style="max-width: 150px;" alt="" /><br />';
-
Effectively, extracts the first image of each topic, thanks!
These days I thought, if we can change this part of the block board news:
<div class="post"><hr />', $news['body'], '</div>
replace the '$ news [' body '],' by the first image of each topic, I tested the code you gave me, but it shows all the first images of all the topics in that space, which of course, was the request the beginning lol.
Excuse me if I annoy you, is that I have days investigating for smf , but have not found anything, only I have found in wordpress :(
-
I found this topic: http://www.simplemachines.org/community/index.php?topic=337240.0
The result would be similar to this topic support: http://simpleportal.net/index.php?topic=10766.0
I'll modify a few the SSi boardnews then add it to a block of the portal. It is similar to what I wanted to do.
Thanks for the support :)
-
Glad that you could find the solution to your request. :)
-
Thanks so much! :)
This is what I have achieved so far:
(http://i.imgur.com/qDUQ3Br.png)
I'm still working in the blocks that accompany him on the portal, I hope I can finish in a few days.
Regards!
-
That looks really good. Good job!
-
Hi langel, this looks pretty awesome...
-
Thank you [SiNaN] & akshtsaklani7 :)