Drupal 7 Views list, add link - drupal

Currently I have a Drupal installation which has colorbox installed, this allows me to upload a group of images with some text, each entry is its own entity but are all listed on the same page.
I was just wondering if there is a way that I can display a custom link under each views item (entity). Is this possible?
I'm looking for a quick way to simply add a link that links to the first image of the colorbox image slider.

First, set your Format to Show: Fields. To do so, click the link next to Show: (refer to the picture below) and change it to Fields.
If your Format is set to Show: Fields, you can add a new field of type Global: Custom text. Then, in the text box that appears, simply insert your custom link. If you need to pull in the URL dynamically, use a Replacement Pattern (see the list under the text box).
If you need to use another field as a replacement pattern, add it in the same way as you added the Global: Custom text field but make sure to check the Exclude from display checkbox so that it is not shown in your view.

Related

Drupal 7 - Display single image from multiple image field in View

I would like to display just single image from field with multiple upload option enabled in my View. The best would be to display the first uploaded image, but It does not matter.
I have tried to add that galerry field to field, and was looking for some settings that will give me that option to show only specific or some images.
Is it possible in View to display single image from gallery?
From views if you are using views to display you content
There is settings for multiple valued field you can display specific number items or single item
Just click on that field you will find this setting
If you need to control this from your node display
Single Image this module helps you
Thanks

How to make a custom menu in Drupal 7

I am new to Drupal and I want to make a Metro-style set of shortcuts to webapps in my Drupal 7 installation.
I want to make it dynamic, so anyone user with permissions can edit them in Drupal.
From what I see, I need the following fields:
Icon URL / Icon Image
Title
Body
Color
URL
So, should I create custom type "My Custom Menu" and use Views module to retrieve them and a views-MYVIEW.tpl.php file? Or can this be done in other simpler way.
Thanks a lot.
I'd use a Node and views to achieve this. I don't think you need a tpl for this, I think some css will do just fine.
Just create your Node with those fields
Create your view as an unordered list
I would make the order Color (hidden), url (hidden), Global: custom text, Image, title, body, Global: Custom text
Set your css on the views row to float left
set your css on the views row to 50%, you might need some adjusting here to allow for the padding
Then just adjust your css to get the other elements in place
For the first global custom text
remove the label
Go to the style accordion and set the Customize field HTML to None
Go to the style accordion and set the Customize field and label wrapper HTML to None
Set the text to something like
<div class="[color_field]"><a href="[url_field]">
For the second global custom text
remove the label
Go to the style accordion and set the Customize field HTML to None
Go to the style accordion and set the Customize field and label wrapper HTML to None
Set the text to something like
</a></div>
The Global Custom text fields will create a wrapper around all of the fields within the views row for your color and link. Look at your Replacement Patterns accordion for the names of your fields in the view, I've used color_field and url_field as placeholders above
I think the best way is to use Views and then style using css. In your view format use either GRID or MASONRY API to achieve the metro layout and show FIELDS. Use the Fields to fetch your desired content from the published content.
You can use special content type and view to get nodes in that type as other people suggested. Also you can use views_get_view_result()
https://api.drupal.org/api/views/views.module/function/views_get_view_result/7
To just get array of nodes and loop trough them on your own, without using any template files. This way you can use totally your HTML and just print out values from results array this function returned.
But, you can do it totally different way. If you are showing this to i.e. your home page you can add all those field describing your menu to home content type and you can use field collection module which allows you to repeat group of fields. So you can make a group of all fields describing single menu item and make it repeatable. And inside your home template file you'll simply get an array of those field groups / menu item objects.
https://www.drupal.org/project/field_collection

Drupal based on check box flag, change the textbox text as link or normal text

This what I am expecting:
If the user filled the textbox, and if the user checked means, while displaying the content on that time, content should show as a link, if the user is not checked, then it need not to show the link while that content in view mode. See the following image for an illustration.
Not an exact solution to what you want to do but I believe the Link Module will display only text if no url is entered.
You can give users a message saying to leave URL field blank and only enter a TITLE if they want plain text.
UPDATE:
You don't need to code any hooks. The CCK Module adds fields to content types. The Link Module adds link functionality to CCK.
No coding is necessary; this can all be done from the admin panel. If you have no idea what I'm talking about see this video.
http://drupal.org/project/conditional_fields module does exactly what you are trying to accomplish. You can use the link_field of cck along with the conditional fields module. So based on the value in the check-box you can choose to display it in the node view.

Drupal: CCK ImageField, multi-line description

I'm using CCK Image field (multi-images) and for each image I have the "Description" field, where I can add the image description.
I was wondering if I can have multi-line description, instead of only one line.
(Even using some specific symbol to go next line)
thanks
If you are wanting a textarea instead of a textfield for the image description field, the only way to do this would be to create a custom module that creates a compound field. There is a really great tutorial on the state of compound fields in Drupal and how to create one here: http://poplarware.com/articles/cck_field_module.
Alternatively, if you only have one image you are uploading, you could disable the description on the image field and create an additional CCK textarea to be used as the description.
When you create CCK imagefield, there is a setting called "Title text settings", where you can set the checkbox "Enable custom title text" and select Input type: textarea instead of textfield.
So now there is nothing you must to specially to make a multiply description for your every imagefield.

DRUPAL: adding CCK image fields to other CCK fields

can I add a CCK image field to another CCK field ? I would like to add icons for each item i add. At the moment I can only write the description.
This would be very cool functionality!
You could do this with JQuery if you want to add an icon by file type. For example see http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/ tip #10.
If you want to be able to specify an icon per item added (so it could be a different icon for every added item) then how you do it depends on how you are displaying it.
So lets say each CCK field is being added to a particular node type and you have a view that lists those nodes then I'd recommend adding a CCK image field to the node (so that each node of the required type has the descriptively named CCK image field and the original CCK field) and then adding a custom template to the view that controls how the image and field are output relative to each other.
I was about to write an example of how to do that but thought I'd check if that describes your needs before I add unnecessary info to the response.... can you clarify what you're trying to do?
You can do this using CCK 3.0's multigroup functionality. Note that there is no stable release for this branch, but it seems to work fine for most use cases.
You would add an image field (icon) and a text field, into a multigroup, and then when adding a new node, instead of the traditional 'add another' button, there is a button to add another group of associated fields.

Resources