Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

Adding the first IMG to the Latest Topic updates

Aloittaja Xpresskonami, heinäkuu 14, 2014, 05:43:29 IP

« edellinen - seuraava »

Xpresskonami



Admin am trying to make updates for my smf like wordpress.


Am using the Rss feed codes for my updates,


<?php $rss = new DOMDocument();
$rss->load('http://www.url.com/index.php?action=.xml;type=rss;sa=news;limit=20;boards=3,2,1,5,6,7,4,10,11,12,16,18,19,14,15,17,47,50,20,23,33,24,26,21,32,36,29,27,31,28,25,30,34,51,38,39,8,9,13,22,21,25,35,36,37,42,40,41,42,43,44,45,46,47,48,49,50');

$feed = array();
foreach (
$rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'Images' => $node->getElementsByTagName('images')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed$item);
}
echo 
'<strong><div class="itemtag">Featured </div></strong><div class="box"><br>';
$limit 15;
for(
$x=0;$x<$limit;$x++) {
$title str_replace(' & '' &amp; '$feed[$x]['title']);
$link $feed[$x]['link'];
$description $feed[$x]['desc'];
$images $feed[$x]['images'];
$date date('l F d, Y'strtotime($feed[$x]['date']));
echo 
'<a href="'.$link.'" title="'.$title.'"><div class="box"><table width="100%"><tbody><tr><td align="left"><img src="http://www.url.com/Themes/icons/news.jpg" height="40px" width="40px"></td><td>'.$title.'<br><div align="right"><font color="green"> '.$img_first.'</font></div></div></td></tr></tbody></table></div></a>';
}
?>


So am trying to add this code to it, to crawl the first image into my Latest topic updates.

function first_img($text,$thumb) {
global $config;
$res = preg_match('#\[img\](.*?)\[\/img\]#is', $text, $matches);
if (!$thumb == '') $text = '<img src="'.$thumb.'" width="50" height="60">';
elseif(!$matches[1] == '') $text = '<img src="'.$matches[1].'" width="50" height="60">';
else $text = '<img src="url.com/Themes/icons/update.gif" width="50" height="60">';
return $text;
}


$showk=preg_replace('#<img(.*?)src="(.*?)"(.*?)>#is','[img]\\2[/img]',$msg);
$img_first = first_img($showk,$img = NULL);


So that it can be like this



But I could not get it. Help please!


Advertisement: