SimplePortal
Customization => Custom Coding => Topic started by: saurabh1938 on January 07, 2015, 01:59:10 PM
-
Hi All,
First of all I want to thank the community for giving such a wonderful support and with the help of it I was able to create a website with minimum coding knowledge.
I am searching for a custom php block in which I can show article Topic name and a first image of article shown adjacent to Topic name.
Can this be done?
Thanks in advance
-
Anybody?
-
i did somethin similar last week
i used to modify sp_articles function to catch and remove all images and first URL from article body
$corpodellarticolo = $article['msg']['body'];
$pattern = "/\[img(.*?)]([^\[]+)\[\/img]/i";
preg_match_all($pattern, $article['msg']['body'], $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$imgs[] = $val[2];
$corpodellarticolo = str_replace($val[0],"",$corpodellarticolo);
}
$pattern = "/\[url(.*?)]([^\[]+)\[\/url]/i";
preg_match_all($pattern, $article['msg']['body'], $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$urls[] = $val[0];
$corpodellarticolo = str_replace($val[0],"",$corpodellarticolo);
}
// trim all double breaks
for ($spazi = 0; $spazi < 10; $spazi++) {
$corpodellarticolo = str_replace("<br /><br />","<br />", $corpodellarticolo);
}
$article['msg']['body'] = $corpodellarticolo;
then I put catched URL and first image in the very first lines of body and let function go on
if ( isset($imgs) ) {
$article['msg']['body'] = '[img]'.$imgs[0].'[/img]<br />'.$article['msg']['body'];
unset($imgs);
}
if ( isset($urls) ) {
$article['msg']['body'] = $urls[0].'<br />'.$article['msg']['body'];
unset($urls);
}
-
which file and where did you put these edits?
-
which file and where did you put these edits?
it works in Sources/PortalBlocks.php
I used to call a custom php block and put in it the modified content of sp_articles() function defining my own vars and parameters
-
too much rocket science for me, can you show me a demo and steps to do it?
-
look here
http://simpleportal.net/index.php?topic=14099.msg70208#msg70208