Common Guys! I know this can't be hard. What would cause this index.php to "break out" of the geeklog wrapper??
Along those same lines, I am having the same issue and am looking for a quick fix. :wink:
I know that according to
http://www.geeklog.net/faqman/index.php?op=view&t=12[*2] you must enable use of PHP, place the code in lib-custom.php, use the function call "phpblock_your_function_name", and finally that it
MUST use return statements,
NOT echo statements, correct?
OK, so I have integrated a separate php calendar script called TotalCalendar. (www.sweetphp.com) (
I am not asking for help with the script, it works fine, but it uses echo statements throughout the entire codebase, and I believe this is why it is rendering above the GL header.
Originally, the code to call the calendar block in lib-custom.php was:
Text Formatted Code
/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/
function phpblock_minitotalcal2()
{
$tcalRootPath = "my path"; // Path with trailing slash
$tcalUrlPath = "my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");
echo "<table><tr><td><div align=\"center\">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table>";
}
So, I changed it to remove the echo statements, and in their place used retvals and a return statement:
Text Formatted Code
/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/
function phpblock_minitotalcal2()
{
$tcalRootPath = "filled in my path"; // Path with trailing slash
$tcalUrlPath = "http://filled in my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");
$retval = '';
$retval = '<table><tr><td><div align="center">' . showCalBox("Current_Month_Mini") . '</div></td></tr></table>';
return $retval;
}
But I get no difference in the final output. Both instances display the calendar block above the header.
An example GIF can be found at
http://familycorner.us/block_funkiness.gif[*3]
So,... a couple questions:
1- Is there an easier way to modify the GL code to allow the use of echo statements in blocks?
2- Are there any security risks inherent in doing so?
3- I assume the issue lies in that all the code that is referenced in the require_once file at times uses echo statements (and subsequent require_once files referenced from that file and so on), yes? This is why I am asking question 1.
:pray:
Thanks in advance for help!
Look into the output buffer functions in PHP:
Text Formatted Code
/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/
function phpblock_minitotalcal2()
{
ob_start();
$tcalRootPath = "my path"; // Path with trailing slash
$tcalUrlPath = "my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");
echo "<table><tr><td><div align="center">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table>";
$retval = ob_get_contents();
ob_end_clean();
return $retval;
}
Hey Joe!
Thanks so much for the quick reply and the advice! It was just what I was hoping for!
Since we went back to using echo statements, I had to add the backslashes to the div tag so my final beautiful results look like this:
Text Formatted Code
/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/
function phpblock_minitotalcal3()
{
ob_start();
$tcalRootPath = "place your server path here"; // Path with trailing slash
$tcalUrlPath = "place your http:// path here"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loader.php");
echo "<center><table width=\"195\"><tr><td><div align=\"center\">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table></center>";
$retval = ob_get_contents();
ob_end_clean();
return $retval;
}
Thanks again for your insight Joe!
Quick question: Are there any security risks inherent in using these output buffers?
You Rock! :chestslam:
Not inherently. But since you are running code you don't really know much about, you are taking a risk there. But the same risk applies to the parts of Geeklog you don't know much about.
Gotcha.
Thanks again for the help!