Jump to content

Recommended Posts

Posted

I am working on a module that runs/previews (for pub/unpub) imports on importer page view. The template has to be in site/templates, so far as I know, so one is created there on install which includes a file to run from within the module, but then when it's run and tries to read the importer csv file it cannot, since it's in the admin, I guess... Is it possible to set the template page to a file in the module directory? Will that work?

  • Like 1
Posted

I have this happening in the template file:

    if(file_exists($filepath)) echo $filepath;
    echo "<a href='$filepath'>csv</a>";
    $file = fopen($filepath, 'r');
    print_r(fgetcsv($file, 0, ',', '"'));
    fclose($file);

where $filepath = $this->source->url (in a class method). So it's the page's attached CSV file's URL. The link works and downloads the file, which supposedly doesn't exist, according to the preceding line. Why??

Posted
On 19.8.2017 at 7:31 PM, hellomoto said:

Is it possible to set the template page to a file in the module directory?

There's $template->altFilename which I think is relative to the templates folder.

Posted

I tried using that with ../'s in the value to grab from the module's directory to no avail.

Here is the module in progress:

The file in question is import/csv.class.php.

I appreciate any and all feedback regarding the makeup of this module.

  • hellomoto changed the title to Cannot read/open CSV file from field in page under admin

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
×
×
  • Create New...