Drupal: how to add pdf links to a block? - drupal

I've some blocks in my Drupal website with some text.
I need to other some links in the text, to pdfs (and upload them from back-end).
Can I add some upload fields to the block pages, and link them from the text ?
thanks

Check out the Insert module, which allows you to upload files to a FileField and then easily link to them from within the node body.

I usually just end up attaching them to a node and then linking them manually. Not the answer you were probably looking for, but it works.

If you have views module available you can create a view that lists the pdfs attached to a particular node, using the node id (nid) as an argument, or use more complicated arguments if you want, as long as the fields displayed in the view are the the filefields you used for your pdf you can get pretty creative with how the pdfs are organized.
It's somewhat tricky to get arguments into views blocks but it's certainly possible, using panels, or using other tricks. More info on that:
here: http://drupal.org/node/150482
here: http://drupal.org/node/695124
http://drupal.org/node/161867#comment-1086587

Might not actually help you, but the D7 version of http://drupal.org/project/block_api creates fieldable blocks, which means that you can attach any type of fields to created blocks.
For D6, the solution is more complex I guess. You could create a separate content type, attach the files there (by using Inline, FileField, ...). Then, either write a custom module that exposes a block for each node of that type and then renders the node in those blocks or use Views to create a view of a single node. Using views would be a bit overkill I guess but should be relatively fast if you can use caching..

Related

Drupal - Show content on specific page

Am I able to add the following field to a content type, so that each piece of content I create can be conditioned to a page?
Or is there a module to extend Publishing Options, where by it adds all the pages I have created (just like 'Promote to Front Page')?
If not, why is no one doing this? As a new user to Drupal this seems like it would be a handy operation. (I have already tried this module but it doesn't achieve the results I'm after).
If none of these solutions are available, what would be the best alternative way of doing this?
I've posted this question on Stack Exchange for Drupal but I need a quick answer and there seems to be a bigger community here :D
You should use Context. With Context, you'll be able to manage contextual conditions and reactions for your drupal like Regions.
Have you used Views? it is one of the most common used drupal modules. It doesn't extend publishing options directly but it does replace it in a way. You can say by example put a list of al content-types: your_own_Content_type that have the publishing options of promoted to front-page. then sort them by title, date, what ever you like.
you could also create only one view and create multiple blocks out of it. you have to understand the logic of drupal: if you want different blocks on different pages, you have to create the different pages AND different blocks
create the view for one type of content-type and make one block out of it. put this block on the desired page. All your other blocks are made with the same view, just adjust a condition in your view and create a new block out of it. You should also put all your blocks in the same region, and set the to the right pages
here you can find a lot of documentation if you run into any problems... drupal.org/project/views
Views is the best at creating a slideshow of images or any type of data on your site.
Used in combination with nodequeue it might offer near or the full functionality you are trying to achieve (check this out ... and this too) - but I don't understand your question entirely.
By my opinion Views is too complicated task for much simple request.
There is a few ideas for solution:
Easy way - You can create a specific template file or add some if statments to the node.tpl.php(specific tpl better)
For minor changes - Create a new context with "path" filter and "theme html" reaction, than hide the field by the css
Best but complicated(large usages) - create a new "view mode" and implement the display by new "hook_menu".
~ Almog

How to add additional fields to a file field/widget in Drupal7

I have a file field in Drupal 7 that I need to add additional fields to.
Currently the only available field is the file upload itself and a description. I would like to add a title field and a dropdown with some hard-coded options. I still require all the functionality of the file field.
How can I do this? I think I need to create a new file widget but not sure how to begin.
Thanks.
One solution is to use http://drupal.org/project/field_collection
It basically allows you to group a number of fields together to a single "thing".
http://drupal.org/project/media is a different approach, which makes images, videos and so on to separate entities to which you can attach fields.
You could also create your own field, but it's probably overkill, http://www.agileapproach.com/blog-entry/compound-fields-drupal-7.
Personally I would recommend the Media module, sadly it's a little buggy right now.

Drupal : how to create a view that displays all the content-types

It may sound 'weird' but I need to have a view that lists all the content types I have.
For example i have two content types : contenttypeA, contenttypeB
I want to create a view that just displays the two content types (and show number of items of that type, but that can be done later).
For now what I did is add one content of each content type and list them but only show the 'node type'; it works well if there's at least one content but I want to display even without any content of that content type.
Any idea ?
Introducing the node_type table to Views requires a custom module and some Views API knowledge however http://drupal.org/node/1001222 will give you a head start.
Use a Customfield: PHP code field and custom code the whole thing with PHP. This is provided by the Views Custom Field module.
Use the Table Wizard module to make the node_type table available to views. You may need to use the Data module as well since they say that all future development is going there.
Expose the node_type table yourself by writing a custom module using the Views API as suggested by chx.
Number one is the quick and dirty way, but number 2 might be a little more manageable, but I am not completely sure it will do everything you want. If you do number 3 make sure you contribute back to the community by putting your module on drupal.org.
There is no native functionality in Views to do that. You can write a static page or (overkill) a module that provide a "system"-like type similar to Views Watchdog.

File attachments in Blocks?

Whats the best way to have file attachments in blocks like you can with nodes? Is this possible with an existing module?
If your attachments are CCK File fields, you can use CCK Blocks module for this purpose.
I think the best course of action, is to create a block and then create a view of the node with a block display. With a bit of work you could automate the process, and don't publish the node if you prefer it not being viewable.
You could create a base view in the views UI and export it, the only thing you would need to configure is the node id.
That is one way of doing this, that doesn't require too much work, and utilize a lot of modules you probably already have enabled for the site.
Use views, create a block display and set it to display file attachments for the specific node type. Set the argument to node ID by providing a default argument and telling to fetch the node ID from the URL.
Bam!

Drupal views: Allowing users to choose sort criteria on node display

I have some nodes I am displaying in a view. They are displayed as nodes, unformatted. I would like the user to be able to choose from some predefined sort criteria ( via drop down list or similar).
So they could pick recently active, most commented, newest, etc., and re-query for new results.
Its easy with tables because you can make the labels clickable, but I do not know how to have similar functionality with a raw node preview display.
Just a thought, from me to me, and for anyone else who may be trying to do this.
An easy, sleezy option would be to just add another page view for each of the required sorts, and provide a link to these other views in the header of each of the pages.
This could also allow for (easier) linking to the individual sorts, so say if you have a sidebar block displaying recently commented nodes, you could adjust the .tpl.php of the block to have the title link to the view displaying the full set of recently commented nodes.
also im pretty sure there should be a way to do this with arguments, but i dont know how
Views 3 supports exposing sort order (just like you can expose filters)
Select the sort order (e.g. add sort by node creation date, then click on the settings for that), you should be able to expose the sort order to the end user. This is just like clicking on the settings for a filter and then choosing to expose it.
Standard views isn't going to support this, so IMO you're best off implementing a custom solution using just a plain old view and this jQuery plugin. You can either do this at the theme layer (the same way as any other JS in a theme) or a custom module (via drupal_add_js() to add the plugin and your bit of custom code). Either way will work, although the custom module has the obvious benefit of being theme independent (and thus more portable).
If you go the custom module route, please consider releasing it as a contrib module on http://drupal.org.

Resources