Page 1 of 1

The editor is in a frame call "pageedit".Passing v

Posted: Tue May 02, 2006 5:04 pm
by Peuplarchie
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Good day to you all !!!
I've find an directory lister and from it i need when the user click on a file that it pass the value to another page, this one in a frame, witch would be a simple php file editor so that he/she could edit the selected file and save it.

Here is thecode use for the directory lister :

Code: Select all

function directory($result) {

$handle=opendir(".");
while ($file = readdir($handle)) {
if ($file == "." || $file == "..") { } else { print "<a href=$file>$file</a><br>\n"; }

}
closedir($handle);

return $result;
}


?>
<b>Select the file you want to go to:</b>
<p>
<?
echo directory($result);
?>
Here is the code for the editor :

Code: Select all

<?php
$file = "index.html";
if(isset($_POST['text']))
{
if(get_magic_quotes_gpc())
{
$_POST['text'] = stripslashes($_POST['text']);
}
$handle = fopen($file, 'w') or die("Unable to open file for writing");
fwrite($handle, $_POST['text']);
fclose($handle);
}

$text = "";

if(is_readable($file))
{
$text = file_get_contents($file);
}
?>
and in an textarea is :

Code: Select all

<?php echo $text; ?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue May 02, 2006 6:26 pm
by Ollie Saunders
What is the problem exactly?

Posted: Tue May 02, 2006 6:45 pm
by Peuplarchie
The dir list should be for html file and when the memeber click on one it should put it self in the editor..

Ther is 2 file in the above code :
dirlist.php and editor.html

editor.html is dived in 3 frame.
one of them is the editor itself


How could from the dirlist.php edit the file select in the editor code above.

Posted: Tue May 02, 2006 6:50 pm
by RobertGonzalez
You will need to use the 'target' attribute of '<a...>' tag in conjunction with naming the editing frame the same as the value of target. I bet if you googled 'Using hyperlinks between frames' you would come up with something good. :wink:

Posted: Tue May 02, 2006 6:57 pm
by Peuplarchie
yeah you're probably right .

I dont know hoe the first script will tell the second wich file to edit ?

Posted: Tue May 02, 2006 7:03 pm
by RobertGonzalez
Left Frame (frame name could be something like "nav")

Code: Select all

<?php
echo '<a href="page2.php?edit_page=$page_id" target="frame_name">Edit ' . $page_name_to_edit . '</a>';
?>
Right Frame (frame name would be "frame_name" as referenced above)

Code: Select all

<?php
if (isset($_GET['edit_page']))
{
    $page_id = $_GET['edit_page'];
    // validate this value, the use it to search for and edit your page data
}
?>

Posted: Tue May 02, 2006 7:08 pm
by Peuplarchie
sorry for my non-knowledge, can you make it mach my code ?
I'm new and learning,....

Posted: Wed May 03, 2006 12:02 am
by RobertGonzalez
Before I do it for you, you should try it out yourself. Really try, and if you run into challenges along the way, post back. Everyone here is more than willing to help you do it. But there are few here that are willing to do it for you.

Posted: Wed May 03, 2006 1:46 am
by Ollie Saunders
Before I do it for you, you should try it out yourself. Really try, and if you run into challenges along the way, post back. Everyone here is more than willing to help you do it. But there are few here that are willing to do it for you.
Yes and besides we probably won't be able to make it work how you want anyway.

Posted: Wed May 03, 2006 8:09 am
by Peuplarchie
That what I doing, I will come back to you !
Thanks A lot !

Thanks It work ! but other page frame ?

Posted: Thu May 04, 2006 7:01 pm
by Peuplarchie
Good day, and Thank you !

NOw that you help me fix this and you understand what i'm talking about, can it be possible and can you point me ti how I can do the same in anothe page's frame ?

Posted: Thu May 04, 2006 8:00 pm
by RobertGonzalez
Something you can do to learn what you want is to download phpBB and take a look at their administration folder. Their admin pages all work that way. There is a left navigation frame that loads all admin pages in the right hand frame. Basically you are going to develop all of your code as though they were regular pages. The only difference is where your tell your markup (the HTML) to get it's source.

Maybe do a little googling for HTML frames for some tutorials on how to use the frame syntax for HTML. That would be a good place to start.