Add an "image" field to entity "views" - drupal

My setup: I'm using Drupal 7 with lots of contrib modules (Chaos Tools, Views, IMCE, etc.) I'm not sure if Views are considered Entities right off the bat, but I'll be asking this question assuming that they are.
My question: How do I add a field to all Views that asks the admin for an image?
The context: I have a sidebar module that lists every View. I need them all to have thumbnails to the left of them.
What I've tried: I've tried looking all over the Field/CRUD APIs but I could not find anything that appends a field called "Image" to the end of the views_view table. I also tried watching some conferences e.g. DrupalCon but I couldn't find anything that was specific to my question.

Don't know exactly what you mean by "asks the admin for an image", but asuming you'd like to add a static image to a view you have the following options:
( probably easiest) add an image tag to a view block template.
If you don't yet have a block template create one in your theme template folder and name it: block--views--{VIEW_BLOCK_DELTA}.tpl.php, copy the contents of the default block.tpl.php into the file and then add the img tag.
Login as admin, go to: structure > views and then click edit on a view you'd like to add image to.
Go to fields section.
Now it depends if you want to use the image path from cck field value OR you want to hardcode it, like you would in the 1st example.
CCK field way: ( first create a cck field of course), add it to your view fields list, go to rewrite result and tick "Rewrite the output of this field" and then add to textarea sometihing like that:
< img src="[YOUR_FIELD_NAME]">
You can also hardcode it, if you don't need it to be stored in a cck field in db:
select a random field, click on it, go to go to rewrite result and tick "Rewrite the output of this field" and then add to textarea sometihing like that:
< img src="trololo.jpg"> [RANDOM FIELD NAME]
This would just append the image next to an existing filed, so with just a little styling you could achieve your goal quite quickly

Related

How to "separate" image uploads while using multiupload image field

My client has a bizarre request which is making it difficult to build a slideshow on profile2 pages: The profile2 pages require 4 photos to be uploaded, and he does not believe that the users adding content to the site will "get" the multi-select method found in most file upload modules. The Field Slideshow module only works if you're using multiupload (which of course makes sense), and that's how I had it set up initially - which worked perfectly. I've tried using the field collection module, then creating a Slideshow view, but the image fields in the field collection field aren't being seen as a group. I think I had to select one of the 4 image fields to use instead of all 4. Any ideas?
he does not believe that the users adding content to the site will "get" the multi-select method found in most file upload modules
This hardly makes sense, I guess you tried to explain things to your client ?
Assuming you have several image fields on your content type, you could build a view which create a list (unformatted or HTML list) of these fields, maybe using a global field rewriting (you add all your image fields, exclude them from display, custom their display by removing field wrapper and field+label wrapper (in order to get only ), add a global text field in which you include image fields token), and then create your slideshow in a custom javascript file, using whatever library you like (Cycle2 is great).
Your global text field would look like :
<div class="wrapper cycle-slideshow">
[field_image]
[field_image_1]
...
</div>
(with cycle2 adding a cycle-slideshow class will initialize your slideshow)
...but you need token to do so.
I often find it more convenient to setup javascript things like that (slideshows, gmaps...) by myself instead of using views integration.
Hope I understood your issue correctly, good luke with this.
For every (custom) field you have option "Number of values" which you can set to fixed amount (i.e. 4) or unlimited. Can you use that?
Easier: Use Rules. Create an additonal (fifth) image field (multivalued) that will be the one consuming the slideshow. Create a new Rule, triggered on creation or update of your content with 4 actions: each one adding the content of one of the fields to the multivalued field list. You probably need to avoid showing that field but that depends on what are you using to display, so hide it using display suite or just not using it in the content template. This way, you show your users your 4 fields but makes the slideshow work based on a computing of the user inputs.

Create a drupal 6 views slideshow from a single content type that has both, image and video fields

I need a little direction. I've created a content type that has both, images and videos attached to a node. I need to create a single frame slideshow that riffles through the mixed media. Currently, I'm using the Embedded Media Field as well as the ImageField to upload the content. I'd like to keep that within the same content type if possible. I was considering separating them and then using taxonomy to make them relational, but that sounds convoluted. At this point, the slideshow displays them both, together.
Could I add both fields to an array in a template file, then return them as one field?
It sounds like you want to add some markup that encapsulates both fields. If that is the case, you can re-write the output of the fields.
Try this:
Edit the "Content: Slideshow main image" field
Enable "Exclude from display"
Click Update
Edit the "Content: Upload Full Size Video" field
Enable "Rewrite the output of this field"
Here you can add whichever markup you want and make use of the field tokens. For example, something like <div>[field_slideshow]<br>[field_upload]</div> Note: The token values will depend on the names of your CCK fields.
Also, for Drupal related questions, there is a separate Drupal Answers exchange where you might get more targeted help.

Drupal 7: Add view to content type

I've been making a template for a particular content type, but just ran into a problem: I need to embed a view into the content type.
I am aware this can be done via several different methods, but I don't see one that fits exactly my needs:
I need the view added automatically for all pages of that content type.
Using blocks in a region is not an option, as I want to avoid defining a region in the middle of a page that should only be available for a specific content type.
Translatable label.
Possibility to freely apply a template to all fields in the content type (excluding the embedded view).
I tried doing it via page layout (Panels) and simply adding node content fields and the view to my layout regions, but then I get another problem: I can't style my content fields without doing something that seems a bit over the top:
Currently I have about 20 different content fields in the content type that are wrapped in HTML and styled in my template file. I have a translated label for each of these in the template file. From what I can tell I'd have to add a template for each of the panes containing content fields to add my translated labels and HTML needed to style each field.
I'm not really fond of making 20 templates, 20 theme hook suggestions to get the templates to work and 20 regions in the panel layout just to get a view inserted in the content type.
Am I doing something terribly wrong here? Any suggestions?
You may want to try the Viewfield module or similar modules (search for "view field" or "view reference").
If you are doing something more complex like changing/filtering the view based on some value in your content type, then you may have to use Viewfield module in combination with something else that will help fill in the filter values.
I've never done something like this before so I'm not sure exactly what module combination would work but Rules or Computed Field come to mind as possible helpers.
You have to use "views node field" http://drupal.org/project/viewsnodefield, after installing this module you have to select the "Node content" in the display (like blocks,page). then click the add display. if you want to display the content like this page http://www.richtown.ae/?q=content/arabian-ranches then you have to download the views_galleriffic module and install it and choose the style option "Galleriffic Gallery". You can choose the content type by using the filter in the views.
That's it cheers
i implemented this in my website richtown.ae
if you still unclear please send me the email social#richtown.ae i will reply you & ready to help you we can share information
i am using this module in drupal 6.
I resorted to using the EVA module ( http://drupal.org/project/eva ).
In addition to Woodgnome's answer
Let's say you have a content type named 'Product'
You want to attach a view to it.
Here are the steps using the eva module :
On your view edit page :
Section Displays
+Add : Eva field
Section ENTITY CONTENT SETTINGS
Entity type:Node
Bundles:Product
That's it, going to a node product type will now display the view

Is it possible to add buttons (link) to a view in Drupal?

I am looking to add separate buttons that will be displayed at the top of the view that I am creating in Drupal.
So far all the fields that I have added appear inside of the table as they should. The only thing that shows outside of the table is the search filter above (as it should).
I would like to add 3 buttons(links) in a row that are positioned above the table and below the search area.
Is there any way to do this in Views? If so could someone describe the process? Thanks!
The most straightforward way to do this is through the theme layer. Edit the view, and go into the Header option under Basic settings. There, you can put in your custom HTML for the buttons.
However, as you might've noticed, this places the header above the exposed filters, whereas you want the header below them. To do this, go into the Theme information option under Basic settings, and find the Display output section.
There, you'll see a list of file name hints. Create a file within your theme using one of those filename hints. Then, click on Display output: you'll receive the default code you'll need to put within your newly created template file.
You'll notice in this new template of yours that the $header code block is before the $exposed code block. Just switch the positions and save your template. Back on the view configuration page, click on Rescan template files, save your view, and the header you've added will now be below the exposed filters.

Drupal theming a row in a view's display

I'm trying to theme a single "display" in a view. What I'm trying to achieve is to have some control over how the row is rendered (eg. print the fields in the row, and maybe add some text in between. along with some divs for styling purpose). I've looked for days for the template to edit. I've used even the Theme Developer and the View's Theme Information, but no luck. All
My view's name is Calendar, and there are a bunch of displays. Could anyone tell me what I should do in order to customize the rows in this particular display? Does drupal even provide this flexibility?
The Name and Title of my display in the Calendar view is:
Name: List view
Title: List
Here's the theme information for row style:
Row style output: views-view-fields.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page.tpl.php, views-view-fields--calendar--page.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page-1.tpl.php, views-view-fields--calendar--page-1.tpl.php
Could someone tell me how to
Edit:
(Some additional information the OP posted in an answer)
I'm using Drupal 6. I'm not sure what page-1 indicates here The following is the list of display I have in this view:
Defaults
Calendar page
Calendar block
Month view
Week view
Block view
Upcoming
List view
Ongoing Block Feed
As you see, none of which has the string "page-1". I edited views-view-list.tpl.php, one of the file listed for "style output". The only variable I have access to is rows, which is an array containing all individual rendered "row". Like I mentioned before, the rows are generated somewhere else, and already contain the rendered fields. How can I customize these rows?
You shouldn't have to add anything to template.php if you are using Drupal 6.
The list of possible theme files that you have there goes in order from least to most specific. For instance, the first one, views-view-fields.tpl.php, will apply to all fields of all views on your site. The last one, views-view-fields--calendar--page-1.tpl.php, will only apply to the "page 1" display of the "calendar" view, so I'm guessing that's the one you want to overwrite.
When you click on Theme Information in the view, the display provided ("page 1" or whatever) applies to the display you are currently on. So if you want to theme fields in a certain display (the "blocky block" display of the "calendar" view, for instance), then you would click the "blocky block" display in the vertical menu on the left, then click Theme Information for that display.
So once you figure out which one you want to use, make a new file in your theme directory with that name, then copy of the contents of the current theme file (click the name of the theme files section on the Theme Information page) into your new theme file, then edit away. Remember, if you overwrite a theme file, you have to click "Rescan template files" in the Theme Information page for the new file to take effect.
Hope that helps!
The displays have custom names on the surface only, but internally they are referenced by id. 'page_1' will be your first display of type 'page' (blocks will become 'block_[id]', feeds will become 'feed_[id]' and so on).
So if you posted your displays in order, 'page_1' would be the 'Calendar' display. You can check this by looking at the links under the display entries in the display listing on the right of the views config page. They will have anchors named '#views-tab-page_1', '#views-tab-block_1' and so on.
As for overriding the templates, be aware that if you add a new *.tpl.php file, you need to reset the theme registry for it to be 'picked up' by Drupal.
Have you added the custom code needed in the template.php file? I know in drupal 5 you need to put code in 3 files:
template.php
views-views-fields--[name].tpl.php
views-views-fields--[name].css
Also you might try:
http://drupal.org/node/128741
answering the second question: the style output is not the template you're looking for. row style is the template that edits how fields are arranged within the row. if you want to edit how a particular field outputs its content, then the specific field template should be edited.

Resources