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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

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

Post 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]
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

What is the problem exactly?
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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:
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Post by Peuplarchie »

yeah you're probably right .

I dont know hoe the first script will tell the second wich file to edit ?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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
}
?>
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Post by Peuplarchie »

sorry for my non-knowledge, can you make it mach my code ?
I'm new and learning,....
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Post by Peuplarchie »

That what I doing, I will come back to you !
Thanks A lot !
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Thanks It work ! but other page frame ?

Post 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 ?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply