2014-09-29, 02:25 PM
Hi guys, So new MyBB user here. I am trying to move away from PHPBB and on to MyBB.
At the moment I am using a custom RSS JCarousel script. You can see it in action at www.fwkzt.org
Now I know MyBB 1.8 doesn't like PHP straight out the box so I installed the PHP and Template Conditionals (2.0) plugin to enable me entering PHP into MyBB.
Now the problem I have is that I have a ?> with in my <?php ?> tags and the plugin thinks this is a end of php tag and closes it off. So only a portion of the PHP script is called.
Is there a work around I can look in to or a different PHP plugin? I would really hate to use some shitty RSS feed widget instead of JCarousel as it's awesome.
Here is my script which is used:
At the moment I am using a custom RSS JCarousel script. You can see it in action at www.fwkzt.org
Now I know MyBB 1.8 doesn't like PHP straight out the box so I installed the PHP and Template Conditionals (2.0) plugin to enable me entering PHP into MyBB.
Now the problem I have is that I have a ?> with in my <?php ?> tags and the plugin thinks this is a end of php tag and closes it off. So only a portion of the PHP script is called.
Is there a work around I can look in to or a different PHP plugin? I would really hate to use some shitty RSS feed widget instead of JCarousel as it's awesome.
Here is my script which is used:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
<script type="text/javascript" src="http://www.ryanhamlin.co.uk/FWKZT/jscripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://www.ryanhamlin.co.uk/FWKZT/jscripts/jcarousel.basic.js"></script>
<script type="text/javascript" src="http://www.ryanhamlin.co.uk/FWKZT/jscripts/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" href="http://www.ryanhamlin.co.uk/FWKZT/inc/jcarousel.basic.css" type="text/css" />
{$headerinclude}
<script type="text/javascript">
<!--
lang.no_new_posts = "{$lang->no_new_posts}";
lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
</head>
<body>
{$header}{$mysteamlist}
<div class="jcarousel-wrapper">
<div class="jcarousel">
<ul>
<!-- PHP -->
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.fwkzt.org/feed.php?mode=news");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$feed = curl_exec($ch);
curl_close($ch);
if ($feed)
{
try
{
$xml = new SimpleXmlElement($feed, LIBXML_NOCDATA);
$cnt = count($xml->entry);
if($cnt > 10)
$cnt = 10;
for($i=0; $i<$cnt; $i++)
{
$urlAtt = $xml->entry[$i]->link->attributes();
$url = $urlAtt['href'];
$title = $xml->entry[$i]->title;
$desc = $xml->entry[$i]->content;
$html = new SimpleXmlElement('<html>'.trim($desc).'</html>', LIBXML_NOCDATA);
$elements = $html->xpath("img|/img|//img");
$image = 0;
$margin = 0;
if(count($elements) > 0)
{
$image = $elements[0]->attributes();
$margin = 40;
}
else
{
$image = "";
}
$desc = trim(strip_tags($desc,"
<p></p><br><b></b>"));
$desc = preg_replace(array("#^(<br\s?/?>)+#","#(<br\s?/?>){2,}#"), array("","<br><br>"), $desc);
$skip = strpos($desc," ",450);
$alt = strrpos($desc,"<p>");
if($alt < $skip && $alt !== false || $skip === false)
$skip = $alt;
echo '<li style="background-image: url(\''.$image.'\');"><div id="announcement" style="margin-left:'.$margin.'%;"><h2><a href="'.$url.'">'.$title.'</a></h2><p>'.substr($desc,0,$skip).($skip==$alt?'':'...').'</p><p style="text-align:right;"><a href="'.$url.'">More❯</a></div></li>';
}
}
catch(Exception $ex)
{
echo "Error Thrown:";
echo $ex;
echo $ex->getCode();
echo $ex->getFile();
echo $ex->getLine();
}
}
?>
<!-- ENDPHP -->
</ul>
</div>
<p class="jcarousel-pagination">
</p>
</div>
{$forums}
{$boardstats}
<br class="clear" />
{$footer}
</body>
</html>