Jump to content

File editing module


minic studio
 Share

Recommended Posts

Hi!

I`m wondering is that possible to write a module to the back office which can write into files (.txt files).
My front office banner links and pictures path are stored in a .txt file so if i want to modify them i need too use ftp , and i thinking is that possible to write a simple module that can handle whit this problem under back office?
If someone has tips ot something pls help me.

Share this post


Link to post
Share on other sites

Seems :) thats the problem for me.
I searched for some php scripts that can handle whit this file editing stuff, the script for its own working fine .
After the search i modified a simple module and tried to add that script but no success ...

<?php
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminTutorial extends AdminTab
{
 private $module = 'tutorial';

 public function __construct()
 {
   global $cookie, $_LANGADM;
   $langFile = _PS_MODULE_DIR_.$this->module.'/'.Language::getIsoById(intval($cookie->id_lang)).'.php';
   if(file_exists($langFile))
   {
     require_once $langFile;
     foreach($_MODULE as $key=>$value)
       if(substr(strip_tags($key), 0, 5) == 'Admin')
         $_LANGADM[str_replace('_', '', strip_tags($key))] = $value;
   }
   parent::__construct();
 }

 public function display()
 {
 }
}

?>



php script

$akarmi = "test.txt"; 

if (isset($_POST['content'])) 
{ 
   $content = stripslashes($_POST['content']); 
   $fp = fopen($akarmi,"w") or die ("Error opening file in write mode!"); 
   fputs($fp,$content); 
   fclose($fp) or die ("Error closing file!"); 
}
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> 
   <textarea rows="10" cols="40" name="content" ><?php readfile($akarmi); ?></textarea> 
   <input type="submit" value="Save">  
</form>

Share this post


Link to post
Share on other sites

prestashop isn't user friendly, neither for clients or developers, so the best way to put it to work is by doing some reverse engineering. I'd suggest to use an editor like tinymce to edit the txt file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More