After grappling for many hours (I thought there was some problem with the module or my drupal setup), I finally realised that with the upload module, the link to a file attached to a node shows only on the node view (clicking the post title, for example). I thought this was just for teaser view, but the attachment doesn't show even in full length view.
For example, if I have a node with an attachment at www.example.com/report on meeting that is a blog entry promoted to the front page, even with full admin rights, I cannot view the attachment on the home page or on my blog page, but only on the www.example.com/report on meeting page
I find this very limiting. It reminds me of 'mystery-meat navigation'. If the file is attached to a teaser, readers are more likely to click on the 'read more' link than the node title. Still, all they will get is the full length post and not the actual link to the attachment.
Are there alternatives? To summarise, I am looking for a way to display the link to the attachment both in the teaser and full length view of the post.
I am using Drupal 4.5.1
Thanks in advance.
Comments
I just made this change myself
You will have to hack the code. Add the following three lines to the upload.module file:
else if ($teaser) {
$node->teaser .= theme('table', $header, $rows);
}
Place the 3 lines above on line 249, which should be the line right after these 3 lines lines:
if (count($rows) && !$teaser) {
$node->body .= theme('table', $header, $rows);
}
So you will then have:
if (count($rows) && !$teaser) {
$node->body .= theme('table', $header, $rows);
}
else if ($teaser) {
$node->teaser .= theme('table', $header, $rows);
}
Thank you!
Thank you!
I can't remember the number of times I have felt happy receiving solutions to my problem here on the forums.
It works great
It works great, except that I am not sure I expressed myself clearly. Either that or things are more clear to me now;-)
What I would really like is the ability to have the links to attachments show up in the following manner:
1.) If teaser is set, depending on the length of the teaser, the link may be either displayed or not displayed - that is, if the posting falls below the teaser length set, the link would be displayed, but if the posting exceeded the set teaser length, the link would only show in full view
2.) If the teaser length is not set, the node would be fully displayed along with the link to the attachment.
Is there any code to do this?
The advantage to this implementation would be that the attachment link would not distract the user by being present on teasers where the posting is greater than the teaser length and there is a 'read more' link.
The user will also have the freedom to keep postings deliberately short (not exceed the set teaser lengths) if they want to make a cryptic announcement and have the links to the attachment displayed.
You'll want the strlen function
Yes, there is code to do this. But you have to write it, first.
You'll need this function http://us3.php.net/manual/en/function.strlen.php. Use that function to determine the length of the teaser and body and compare them. I'm not going to spell out the code for you, you'll have to figure that out.
--
Get better help from Drupal's forums and read this.
I'm not going to spell out
Ah! Thanks for the php link, but sometimes, life simply doesn't give you time to do what you like best. Until then, I have no choice but to depend on the kindness of fellow Drupallers;-)
Sorry, it's not that I don't want to help
But as you stated yourself: "life simply doesn't give you time to do what you like". Your other option is to pay someone if you can't find someone else who is willing to volunteer to help.
--
Get better help from Drupal's forums and read this.
That's fine. The code that
That's fine. The code that you gave me is a big step forward. Thanks for the help!
Alternative display
After spending multiple hours working on this walkah helped me with the missing function. (As an aside: anything in here that's retarded is entirely my own doing.) I'm now using the following in my node.tpl (well actually it's in THEMENAME_node() in THEMENAME.theme but that's because I'm just using the simple PHP templates instead of something smarter)....
theme('upload_attachments', $node->files)My exact implementation looks like this:
Note 1: I'm using Drupal 4.7 for this site.
Note 2: I don't ever want "links" displaying on this site so I've taken where they would normally show up and changed it so that (1) on "private" pages (2) the uploaded attachments are listed. Checking which term is listed came from: http://drupal.org/node/83121 Ideally I'd have this by "vocabulary/2" instead of having to add each category manually. But for me this is an acceptable start.
Note 3: "private" pages are defined using the taxonomy_access.module.
UPDATE: I just noticed the set of attachments appear twice on the node page itself. To fix this I changed the first line (190 in the example above) to the following:
190 if (count($links) && arg(0) != "node") {That information comes from: http://drupal.org/node/23348