Working on a widget system for my template system and made it that all widgets divs html/php are saved inside variables. Though one of these requires another file to be included ( and the output to be saved inside the widget variable ), which doesn't seem to work. This is the codes it's regarding to:
sidebar.php
$widgets['mainPolls'] = " <div class='rect'> <span class='heading'>Polls</span> <p> ".getMainPolls(TRUE)." </div> ";
system.class.php - (important part of function getMainPolls() : what it returns)
return eval( 'include($set[\'cms_absolutepath\']."/templates/".$set[\'cms_template\']."/poll.php");');
And the function that gets the widget variables and outputs them in correct order @ correct hook:
system.class.php
public function getWidgets($hook) {
global $set;
include($set['cms_absolutepath']."/templates/".$set['cms_template']."/sidebar.php");
//hook would be for ex. 'sidebar-left' or 'sidebar-right'
$select_widgets = mysql_query("SELECT * FROM widgets WHERE template = '".$set['cms_template']."' AND hook = '$hook' ORDER BY orderid")or die(mysql_error());
while($widget = mysql_fetch_assoc($select_widgets)) {
echo $widgets[$widget['name']];
}
}
What it currently outputs for the poll widget ( which includes another file's content into the variable of the widget using eval ) is the content of the poll file included from the getMainPolls function unalligned at top of the page and then the div ( surrounding the getMainPolls file and so the div in which this content SHOULD be alligned/put in ) hanging on bottom of page alligned under the other divs ( but empty ).
Anyone can help me?
Thanks in advanced!
EDIT: Seems the eval makes it include the file content first instead of outputting the file content inside the variable $widgets['poll']... how do I fix this? ( make it put the content of the file inside the variable at the place of where the function getMainPolls is called inside the var ).


Sign In
Create Account


Back to top









