Drupal Views question - drupal

I want to display a different set of 2 or 3 images in a block on each page. So far, I have:
Added images to each page using CCK and filefield.
Removed the images from $content.
Created a view with node ID (Nid) as the argument, and added the field created with CCK, and added display type of Block.
When I try the Live Preview, it will display all the images for all pages in the block. When I enter the Node ID variable, it adds a where clause to the sql query and displays the correct images for that page.
How (where) do I set it up so that the view recognizes that it is on Node 3 and displays only the images for Node 3.
Thanks
John

"How (where) do I set it up so that the view recognizes that it is on Node 3 and displays only the images for Node 3." -- you can do this by clicking on the settings for the Nid argument in Views. Under Action to take if argument is not present: choose Provide Default Argument. In that, choose Node ID from URL
Position your block in the appropriate region (left sidebar, right sidebar etc). Make sure the visibility settings of the block are such that it only appears at paths that match node/*

Related

Drupal: display views page instead of default node/%

Case is that im using views for displaying each of content-types.
eg. q=?news/12 for news by nid
q=?product/13 for products by nid
Problem is when im creating (or editing) new content, it automatically displays (or refer) ?node/14 instead of ?product/14. Also menu link is created under node/14 link.
How could i set each view to referring content type?
Thanks in advance.
You can create a view (display mode : page) for each content type, which displays datas from your node (fields or whatever you need). To do so, add a contextual filter in your view, on content nid, give default value : content nid from url. Then give to this view a url like "/news/%". So "/news/12" hits this view and grabs data from news content type with id 12. Then you can manually modify menu link, or use pathauto to specify /news/[node:nid] as a pattern for all your news nodes (I never tried all this stuff together but it should work).
Other solution : https://www.drupal.org/project/contemplate (seems deprecated...)
Other solution : create a .tpl for your content type nodes : node--news.tpl.php, but no more views...
Other solution : create a view displaying one particular node data (like I explain first with a contextual filter), this view creates a block (display mode : block), you assign this block to a region (with block interface), and set this block to be displayed only for the news content type (last menu on the left on the block configuration page). Then with Display Suite you hide everything for this content type on the full content display. So on each node page which refers to a "news" node, you have nothing in your page but your block (and the node title, which you can remove with display suite extras I guess).
Good luck with it

Dyamic menu links how to

I have a menu block to the right of my content area. I want to be able to click on one of the links and have the content in the content area change, whether that be to advance a nodeque to the matching content type or just diplay a block containing that one content type.
I would usually do this with php, by adding a url variable site.com/data?uid=somenumber to display the data i want on the same page. I don't want to have to create multiple content pages to do this. There has to be a way that the links that are created and displayed in the menu block can just change the content inside the view displayed on the page.
Im a total drupal newb. So any help would be incredibly appreciated.
Thanks in advance.
If your content area is displaying a view, you can definitely do this using views arguments. So, for example, if you want the menu links to vary the view content based on different terms, you can set up your view to expect an argument from the url.
To set it up:
Add a 'Contextual filter' to your view (under the 'Advanced' section)
In my example below, I've added 'region' as my contextual filter, which is just a term reference on my content type
When configuring the contextual filter, set it up such that when the filter is not present in the URL, it just displays all values (that's the default) -- shown in screenshot.
4.
This way, when you first load the page, and no menu item has been selected, all your content will show in the view. Now you'll have to set up your menus to provide the argument, and your view should react appropriately!
Let me know if that works or if you have any questions.

Unable to use multiple images in a single node to create a a slideshow in Views

First take a look at my node setup here: http://imgur.com/a/DJdRw
The first image is my Subpage slider content type which accepts multiple images and will essentially be my slideshow.
Second image is the default page, but I added a node reference to the Subpage slider node. It allows you to associate a particular slideshow to a page.
The last image I was messing around with Views and Views Slideshow, but I don't know what I'm doing. I managed to get images displayed, but as you can see it displays the images of a long vertically. I set the Views slideshow and it creates a slide between multiple nodes and not the multiple images in ONE node.
Where do I go from here?
Thanks
To display a block with a slideshow of images (from a referenced node) when viewing a page
I have come up with a much easier ("duh" moment) way of doing this. I created the functionality on a fresh Drupal install. Assuming you have the following modules: CCK (w/ Node Reference enabled), Views, Views Slideshow, FileField, ImageField.
Create your content types (in this case: slider and using the core page type)
Add an imagefield to the slider content type (field should be named field_images)
Add a node reference field to the core page content type (field should be named field_slide_ref)
Edit the node reference field settings (can remove "Required" if you like)
Create a new view called slideshow
In the slideshow view:
Change Basic Settings->Style to "Slideshow"
Add the field "Content: images" (choose Format: Image at bottom, unless using ImageCache)
Add an argument of "Node: Nid" with the settings:
Add a "block" display
Enable your new block labeled "slideshow: Block" at example.com/admin/build/block
If configured correctly, when viewing a page with the _slide_ref_ field referencing a slider node, you should see the slideshow displayed in the block.
Old Solution...
To display a referenced slideshow inside the page node being viewed:
Download, install and enable the View Reference module
Create your content type with multiple images (Subpage slider) [Done]
Create a new "page" view in Views UI. Add the field Content: YOUR_IMAGEFIELD (from Subpage slider) important: don't group the images, under Basic Settings->Style choose "Slideshow" and add an Argument of Node: nid choosing Provide default argument->Node ID from URL as argument settings
Create a view reference field on your page content type where you want to see the slideshow and select the view(s) that can be referenced and in the "Arguments" fieldset check: Allow delimiter seperated values and click "Save field settings"
Now when you create a default page there will be a view reference field to select the view you want to use and an argument field where you can input the node id of the node with your images you want to show as a slideshow in your page.
THE QUICK SOLUTION: a really simple tweak which the Views Slideshow docs should put in lurid bold gothic writing:
If you want to slideshow multiple images from an image field of one node ** don't forget to untick the "Group multiple values" checkbox in the settings for your-view>Fields>your-image-field **
This outlines how to make a slideshow of images that are taken from one node. The main point here is that you have to make a block that has an argument of node id taken from the url. I used this to make a slideshow showing as a block in the main content area, but you can of course put the block anywhere.
Modules:
CCK
imagefield
views
views_slideshow OR jCarosel
Create your Content Type with an image field, allowing multiple values.
Create content with multiple images, distinct enough so that you can tell if the images are from one particular node or another node
Create a new view as a node.
Create a Block display
Give your block a name (under Block Settings, left column)
Filter as: published, as your Content Type and with the image field (important - see last step why).
Field: your image field.
Make sure to uncheck the 'Group multiple values' checkbox
Display as an image, or an imagecache preset. Whatever you like
Add an argument:
Node: NID
For 'Action to take if argument is not present', select 'Provide Default Argument'
Node ID from URL
Under 'Basic Settings' select
If using views_slideshow, select the Style to be: Slideshow (Single-frame).
Items to display: unlimited
Save your View
Go to your Blocks page (/admin/build/block) and place your newly created block into the main content area (or wherever you want it to be). If you need to set the visibility on the actual block itself (/admin/build/block) then go ahead but otherwise only nodes of the content type that has multiple images will show the slideshow of images, while other pages on your site will not. This is why it is important to set a specific filter and to use the argument.
Done!
Essentially, this does not work as a page but has to be a block. The slideshow will use the NID to see what images are in that node and create a slideshow of those only.
Should work the same in Drupal 7 but have not tested this.
The solution is to add as argument not the 'node id' but the 'slideref field' and provide default argument 'nid by url' and the slideshow by node will work.
You can use the Views Nivo Slider as well.

Drupal - menu items linking to the same node do not display all children

i have got a menu structure like this:
-menu item level 1
--menu item level 2
---menu item level 3
all items are linking to the same node. now, if i visit the node only the first two items are displayed. what i found out is: when i change the link of the first level menu item to something else, all level get displayed right.
menu modules i use:
Menu block
Menu Settings per Content Type
Menu Trails
Administration menu
Auto Menu Title
Hierarchical Select
any ideas?
thanks
lukas
googletorp is right-- Drupal's core menu system isn't designed to handle this. However you can use a workaround.
Let's say that you'd like to create a nested menu in which one of the children links to the same path as its parent. Something like:
people/friends
people/friends
people/family
people/neighbors
This works in theory-- the menu items will take you to the correct page. But if you're relying on Drupal to correctly set the active trail and expand the correct sub menus, you'll have to use a bit of a workaround. You're basically going to create dummy nodes that will redirect to the desired page rather than creating two menu links that have the exact same path. The parent (in menu) will redirect to the child's node.
Method 1 (D6 only):
Download and install CCK Redirection
Create a Content Type 'Redirect Node' and add a CCK Redirection field to the content type
Create a page node (node 1) with URL "people/friends" and add a menu link
Create a 'Redirect Node' (node 2) and create a menu link for this new node.
Set CCK Redirection field to the URL node 1 (people/friends).
Set node 2's menu item to be the parent of node 1's
Method 2 (D6&7):
If you want to get really fancy, you can take a more user friendly approach by combining CCK's Node Reference module with the Rules module.
Download and install the Rules module (and Rules UI) and enable CCK's Node Reference module
Create a Content Type 'Redirect Node' and add a Node Reference (D6) (D7) field 'field_redirect_target'. Be sure to configure this so that it is required, and users cannot select nodes of type 'Redirect Node'
Add a new rule via the Rules module when content is going to be viewed if content is of type 'Redirect Node'
Redirect to page: [node:field_redirect_target-path]
Create node 1 of type page
Create node 2 of type 'Redirect Node'
Set Node Reference field to Node 1
Set node 2's menu item to be the parent of node 1's
This method is a bit nicer for users, since it doesn't require them to find the system path for the target node.
Depending on your setting, the menu module will show the active link it it's children. It is, however, not designed to search for more than a single link. This is why you wont get the full nested menu structure. My guess is, that the top one is the link it finds first, and that is where it stops. I can't remember the algorithm for the menu structure, you might have luck rearranging the menu structure, making menu 1 the last child. This is, however, not something the Drupal menu system is designed for, and you will not have an easy time changing this.
What are you trying to accomplish by linking the same node several times is a nested menu structure?
I solved my problem using menu first child. I didn't look at the code it uses, but it simply works. It's really a bummer that this doesn't work out of the box and you have to use such workarounds. But actually this increased usability for my case.

Drupal: How to show specific view in a particular block

Let's suppose I have created a view that shows some kind of stories.
But I want to show this view in a left-hand bar — not a link to the view, but the view itself.
How can I connect my new view with a fixed block position?
I want to be able to show real view data in various places on my page.
Is it possible or I am limited only to central area and links to views from menu?
Using Views 2.x for Drupal 6.x it's simple to create a block from a view. Every view has a set of 'default' settings and some number of display settings. A display can be a page, a block, a feed or anything else that creative module authors.
To make a block from your view, you just "Add Display" of type "block", override any settings that you want changed in the block (IE - display less items, just a node title, whatever). You then have a block that you can place like any other Drupal block.
edit: Answer to "Can you limit stories to ones that are tagged"? Sure thing. You just add a filter for Taxonomy terms.
Getting a view to display in a block is easy. Once you have created a view and assigned the view as a block position you simply head to blocks in your admin and you'll see the view.
Just select the block and save it. Simple.
If your view doesn't show, check your filters and that the view fields are correct. Usually if they are not showing it is something simple like selecting content published = yes.
You can create views as pages or blocks. As you're not telling exactly which Drupal/Views version you're working with, all I can tell so far is that, after you create the view, you can tell it to display as a block or as a page.
Then go to the blocks settings and set that to the position you want.

Resources