Good day.

Situation:

  • We are using Drupal 5.
  • I do not have access to upgrade, add modules, change settings, et cetera.
  • I have access to add pages and put in some PHP code.

Problem:
I have been asked to add some PHP code to read a CSV file dropped into the file structure. Note that in Drupal the pages are not actually in the file structure, so I can not just do a file read from the page's current directory. I am uncertain how, in a Drupal page with the format set to PHP code, to read the file from a certain directory in the file structure. Web searches have revealed many pages describing the use of various modules and such which I can not install.

Any help resolving this problem would be greatly appreciated. Thank you.

Comments

yelvington’s picture

No way should you be running Drupal 5 in a production/Internet-connected environment.

Noobtastic’s picture

I do not have access to upgrade, add modules, change settings, et cetera.

Noobtastic’s picture

Sorry. The Drupal is v7, the database is v5.

Noobtastic’s picture

Three weeks. No ideas?

jaypan’s picture

I think the last time I worked on a Drupal 5 site was around 2009 - hard to even remember how things work.

I'd create a page callback with hook_menu() that reads in the file. Then generated some nodes, and use node_save() to save them. Do some googling for 'programmatically create node'. You will find D6 stuff, it's slightly different from D5, but not drastically so.

Contact me to contract me for D7 -> D10/11 migrations.

Noobtastic’s picture

I made a mistake. The Drupal version is 7, the database is 5.

While I have done a little PHP before, I have not done Drupal development.

Is there really no way to simply plug basic PHP code to read a file into a Drupal page?

jaypan’s picture

Then you made another mistake - you posted in the code section of the forum, when you are looking for a non-coding solution.

Either learn custom module development, or take a look at the Feeds module.

But it sounds like you are trying the impossible. You cannot add modules, and you don't know how to write your own code. Seeing as those are your two options, I'd say that what you want to be done can't be done with your limitations.

Contact me to contract me for D7 -> D10/11 migrations.

Noobtastic’s picture

PHP coding is coding. I requested information about adding PHP code into a Drupal page to simply read a CSV file. As I stated previously, I have some experience with PHP but not Drupal, and I do not have access to change anything about the Drupal environment. I am seeking a PHP solution which is not a Drupal modules editing solution.

Noobtastic’s picture

I know it has become common practice for kids on the Internet to just be rude and snarky because they believe it gains them points in life. But it doesn't. If you have nothing helpful to say, then don't go to all the effort of posting.

Does anyone have anything helpful to say?

jaypan’s picture

It's nice to be called a kid.

Anyways, was this not helpful:

But it sounds like you are trying the impossible. You cannot add modules, and you don't know how to write your own code. Seeing as those are your two options, I'd say that what you want to be done can't be done with your limitations.

I know it's not the answer you wanted, but it's outlining how your limitations have placed in you in a position of not being able to accomplish the goals that have been set out.

Actually, the fact that you cannot add modules means that even if you can write your own code, you won't be able to add the module for that code to be used.

You need to step back and remove that limitation - why is it that you cannot add modules? This restriction is crippling you.

Contact me to contract me for D7 -> D10/11 migrations.