Love this module but I like to use the filefield and filefield path modules to rename uploads and store in specific locations. The problem I have is that when attaching a file, it shows the wrong file url, only when after saving the page does it then shows the correct updated file url.

Any ideas how I can sort this?

Comments

iva2k’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure that I understand the problem and the feature requested. For the problem - can you list a step-by-step, expected and actual behavior. For the feature request - I want to see use case (if its different from the problem).

Also, did you check this issue #510730: filefield support if it is a duplicate?

iva2k’s picture

Category: feature » bug
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No activity for more than 32 weeks, and this is not a filefield module, so closing as bug/cannot reproduce.

ryanilg’s picture

Component: User interface » Code
Category: bug » feature
Status: Closed (cannot reproduce) » Active

I hate to reopen old topics but this is actually pretty easy to reproduce... It would be super handy to make this work. Yes iTweak is not a FileField module, but FileField Paths actually has path settings for both CCK Filefields as well as files uploaded via the default Drupal uploads module.

1. Install FileField Paths
2. Install iTweak Upload
3. Set a path for all file uploads on a specific content type. Located under Workflow Settings on /admin/content/node-type/[content-type]
For example, attachments/[type] will upload all files into /sites/default/files/attachments/page for page content type.
4. Create a new page and upload a file via Attach/Upload fieldset.

The file path displayed under the uploaded file displays the name of the file, along with whatever the path setting is in File System (files folder).

It does not seem to take into account the settings set by FileField Paths on first display, but when you save the page, and re edit the page, it loads the actual file path from the database.

It just sucks because on first upload of the file, it shows the wrong url, so you have to save, then edit again to copy the correct path into the "Body" area if you want to link to the file.

This should actually be an easy fix, as it could just check for the presence of the FileField Paths module, if it exists, gets the prefix for the currently edited content type and insert it between the filename and default upload path.

markhalliwell’s picture

I'm actually interested in this topic because I have the same problem. I remember seeing this issue in the FileField Paths issue queue at one point but don't have the time to searching right now. From what I gathered though, the issue is because when you have a new node, there is no nid established yet. So if your FileField path uses that token or anything related to it (say Path aliases), you're SOL until it's created first.

Once the node is saved, then the correct paths are shown of course. What would be interesting to see is if we could find a way to dynamically do a regex search in the body for the files once the new node is saved. Although I'm seriously tempted to say this is more of a FileField Paths issue at that point (part of it's retroactive updating maybe?)

rbrandon’s picture

StatusFileSize
new778 bytes

Subscribing, I would be interested in this too.

Currently I have a patch that makes the itweak_upload thumbnails part of the node object and then use a ugly string replace in nodeapi to replace the paths.

        $tmp_node = clone $node;
        $tmp_node->files = $tmp_node->itweak_upload;
        if (($ffp = filefield_paths_get_fields($tmp_node, $op)) != FALSE) {
          $count = array();
          foreach ( $ffp['#files'] as &$file ) {
            if ($ffp['#settings'][$file['name']]['filealias']['display'] == TRUE) {
              $filefield_paths_alias = 'filefield_paths/alias/' . $file['field']['fid'];
              if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) {
                //If alias exists replace it
                $node->content['itweak_upload']['#value'] = str_replace($file['field']['filepath'], $alias, $node->content['itweak_upload']['#value']);
              }
            }
          }
        }
rbrandon’s picture

StatusFileSize
new629 bytes

Attached is a second patch which addresses the display of files in the node or teaser, it checks if filefield paths is installed and if it is and a path alias exists it uses that instead.

If this could be included it would be a good enhancement, with no drawback.

Thanks,
Richard Brandon

iva2k’s picture

Status: Active » Needs review

Thanks everyone for the information and @rbrandon for the patch.

I have little bandwidth to do testing myself. Can people review and post here - does it solve the issue? Are there no side effects? Also, what if both filefield_paths and private_upload modules are active?

iva2k’s picture

Status: Needs review » Fixed

No activity for over 4 weeks - consider the issue fixed. Please reopen with detailed explanation how to reproduce if the issue still persists in 6.x-2.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.