need a little assistance with coding

crnogorac081

Fortunately everything is working fine so far.

Now I am cleaning the code and after that I will post it so everyone can test this reordering..

Web developer

WebBird

Quote from: crnogorac081 on February 01, 2010, 04:08:24 PM
Well, you have permission to read/write/execute if you are loged in via backend, right ?

WB Backend permissions <> file system permissions. :wink:

You don't have permissions on file system automatically if you're in WB backend. You should add some error handling to find out what's wrong.

crnogorac081

#7
Your function is much simplier, I am looking forward to use it in some other cases, but for this specific case I would need to change core code in WB backend theme for this to work...and I would really like to avoid that.. [im working on implementation of drag n drop reordering for modules..]

Well, you have permission to read/write/execute if you are loged in via backend, right ?

The main problem here is that I am working with Backend , so I must avoid to edit header and footer page.. And droplets cant help me..

Thanks a lot for assistance WebBird
Web developer

WebBird

If you (which means in fact "the webserver process") have write permissions in that directory, it should work. With my solution you don't need to create a file dynamically, but it's your choice. ;)

crnogorac081

#5
Thank mate, but I just found and tested a solution:


<?php
// This makes path to current  folder
$filepath=str_replace(basename($_SERVER['PHP_SELF']),"",__FILE__);

// if you are not sure where you are, you can uncomment this and see..
//echo $filepath;

// Now we write the code, just like in Droplets
$dragscript '$(document).ready(function(){ '."\n"

$dragscript .= '    $(function() { '."\n";
$dragscript .= '        $("#dragableTable ul").sortable({ opacity: 0.6, cursor: \'move\', update: function() { '."\n";
$dragscript .= '            var order = $(this).sortable("serialize") + \'&action=updateRecordsListings\'; '."\n";
$dragscript .= '            $.post("'.WB_URL.'/updateDB.php", order, function(theResponse){ '."\n";
$dragscript .= '                $("#dragableResult").html(theResponse); '."\n";
$dragscript .= '            }); '."\n";
$dragscript .= '        } '."\n";
$dragscript .= '        }); '."\n";
$dragscript .= '    }); '."\n";
$dragscript .= ' }); '."\n";

// Now we set the filename in my case: backend_body.js (I needed this code to be written in JS, so I can getl  WB_URL from config.php file )

$myFile $filepath.'/backend_body.js';
$fh fopen($myFile'w') or die("can't open file");
fwrite($fh$dragscript);
fclose($fh);
?>



This is the tutorial how to have PHP code inside Java script (description for search)

Now just another question, will this fwrite work on every server ?

I keep learning php every day..

All best,
Ivan
Web developer

WebBird

I have an easy solution for this case. :-D

Create a backend.js, add:


function setVar( varname, text )
{
    eval(varname+"=\""+text+"\"");
}


In your modify.php, add somewhere to the HTML:


  <script type="text/javascript">setVar( 'WB_URL', '<?php echo WB_URL?>' );</script>


In your backend_body.js, use:


var WB_URL;
...
$.post( WB_URL+'/update...');

crnogorac081

#3
I know, but that doesnt solve the issue as I need to call a file:


<script type="text/javascript">
   $(document).ready(function(){

       $(function() {
           $("#dragableTable ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
               var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
               $.post("'.WB_URL.'/updateDB.php", order, function(theResponse){
                   $("#dragableResult").html(theResponse);
               });
           }
           });
       });

   });
</script>


So I need to have WB_URL variable inside..

I also trried to use a droplet, but it doesnt work in backend..
Web developer

WebBird

Just put your JS into backend_body.js. WB will load it automagically. (Needs WB 2.8 )

crnogorac081

Hi,

I am trying to insert dynamic JS into backend's footer

the code is in modify.php file and I used this from droplets, but it is not working..



$wb_page_data = str_replace('</body>',$dragscript."\n".'</body>', $wb_page_data );


Or this is working only with droplets ?

Could you please tell me how to make this work ?
Web developer