Author |
Message |
dezina
Theme Guru
![](modules/Forums/images/avatars/005.gif)
Joined: Dec 26, 2002
Posts: 57
Location: UK
|
Posted:
Wed Jan 14, 2004 8:23 am |
|
Code:<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
function directory($result)
{
$handle=opendir("./users");
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { print "<a href=users/$file>$file</a><br>\n"; }
}
closedir($handle);
return $result;
}
$content .= "Select the users home page:";
echo directory($result);
?>
|
Works, but the result is shown above Block Title, not in actual Block.
Any advice or help gratefully received . TIA |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Jan 14, 2004 9:26 am |
|
You can't echo in a block. All output of a block must be handled through the $content variable. Try something like $content .= directory($result);
I also notice that you are passing a value ($result) to the function but their is nor $result in the block code outside of the function. Could just be that you don't have all the code. Just an observation ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezina
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 9:48 am |
|
Thanks Raven, I've obviously not coded correctly.Am trying to list folders that reside in a directory on server, and the blocks gives links to those folder. When clicked, the user should be taken to index.html file in each of the folders, depending on which link clicked. Any advice here on how I go about this please? TIA |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 10:03 am |
|
I haven't tested this, but you might tryCode:<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
function directory()
{
global $content;
$handle=opendir("./users");
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .= "<a href=users/$file>$file</a><br>\n"; }
}
closedir($handle);
}
$content = "Select the users home page:<br />".$content;
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezina
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 11:28 am |
|
Raven, regret no joy, but thank you very much for trying. ![Wink](modules/Forums/images/smiles/icon_wink.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 11:37 am |
|
Are you sure the fucntion is working correctly? Try inserting
echo $content;
after the closedir($handle); statement and see if it prints anything above the block. If not, then the function is not working. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezina
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 11:56 am |
|
My original coding produces the desired result, BUT it prints the link/s ABOVE the Block title, and not in the actual block, so am assuming that function code is working correctly, just that my code is putting it outside the actual block ![Confused](modules/Forums/images/smiles/icon_confused.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Jan 14, 2004 12:50 pm |
|
But, I need you to try what I suggested to help me in debugging it. Thanks. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezina
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Jan 15, 2004 4:17 am |
|
Understood.
Code:<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
function directory($result)
{
$handle=opendir("./users");
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { print "<a href=users/$file>$file</a><br>\n"; }
}
closedir($handle);
echo $content;
return $result;
}
$content .= "Select the users home page:";
$content .= directory($result);
?>
|
Produces...
Link
Link
Then: Block Title(PAGES)
Then: Select the users home page: |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Jan 15, 2004 4:50 am |
|
First, a question. Did you use the global $content statment in my code I told you to try up above?Code:<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
function directory()
{
global $content;
$handle=opendir("./users");
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .= "<a href=users/$file>$file</a><br>\n"; }
}
closedir($handle);
}
$content = "Select the users home page:<br />".$content;
?>
|
If that doesn't work, then this shouldCode:<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
function directory($result)
{
$content = "";
$handle=opendir("./users");
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .= "<a href=\"users/$file\">$file</a><br>\n"; }
}
closedir($handle);
return $content;
}
$content .= "Select the users home page:<br />";
$content .= directory($result);
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezina
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Jan 15, 2004 4:58 am |
|
Thank you so much Raven, Second Version works just fine |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|