Creating a view for a node - drupal

I'm having some problems creating a view for a node within my website.
The content has a path of 'content/%' where % is the title of the node.
What I tried to do is to create a page view in the Views2 module, but to no avail.
When I attempt to preview with the name of one of my nodes, nothing appears, and when I visit the node live, it renders text to the screen without any formatting.
Here are some of the settings from my View...please let me know if I should provide any extra information!
Page Settings
Path: content/%
Arguments
Node:Title
Title: %1
Action to take if argument is not present: Provide default argument
Default argument type: Node ID from URL
Edit
I will describe the behavior I'm expecting to see...
I have a list of nodes in my website in a view....that shows up without any issue.
What I would like to do is click on the node and go to that node's page, which is basically an expanded view of a single item from my list.
I thought what I could do is clone my list view and then add an argument to trim the scope from a list to a single item, but this isn't working too well. What is the proper method for styling a single node?

Edit:
Based on your edit, you've already used Views to create a list of nodes, and now you want to be able to click on one and get to the node page.
If you just want the default node output, you shouldn't have to do anything else. Don't try to use a View to override default node rendering; Drupal will print it out by default.
If you want to theme your node uniquely (beyond what moving the fields around and changing display settings in the UI allows you to do), then you should look at custom template files and theming. Resource here: http://drupal.org/theme-guide
You can change the default node.tpl.php file if you want to change how all nodes are displayed, or you can copy that file and rename it to node-name_of_custom_type.tpl.php to uniquely theme a custom content type you've created, but I'd suggest reading up on the Drupal theme system before making those changes.
End of edit
When you want to assign a path to a Views Page display, you shouldn't model it after any existing paths (e.g. node paths, as you mention). It should be something unique to avoid path alias conflicts. So for example:
my-path/%
Now, if you're just looking to embed a view inside of your node (and you want to pass along the node id as the argument), you're half-way there. Your Arguments setting, based on your description, is correct. However, you don't need a page display.
Here are a couple of options:
Quick 'n' Dirty: Create a block display (which doesn't need a path) and stick the block in a region on the node page (I've used the content_bottom region) to "embed" it in your node
Powerful, Flexible: Use the views_embed_view function (api docs here) inside your node (the body or a CCK field, just make sure to use the "PHP filter" input format)
If you use views_embed_view, you have the flexibility of sticking your Views results wherever you like, and you don't even need to create a Views page or block display, because that function can just use the "Default" display.
Note: If you export your View and save the export code on a site like pastebin or drupalbin, folks here can import the View and see it directly to help answer your question in full detail.

Okay, got it. :)
Using Node: Title as an argument is pretty tricky: with the default settings, the argument must match the title exactly. So, if you wanted to match on "Test value", your path would need to look like content/Test%20value (note the caps).
This will get you the node you want. You said you have default argument set to Node ID from URL; that really doesn't apply for Node: Title arguments. What it does is attempt to find a numeric Node ID and use that as the argument, which will never validate on a Node: Title unless the node's title happens to match the node's ID.
If you just want to display all the nodes if there isn't a title argument present, select Display all values as the action to take if an argument is not present. If you want to display all nodes if the title argument is invalid (like a typo or something), make sure Display all values is set in the Validator field group for the action to take if the argument does not validate.
Because of the exact match restriction on node titles, it's generally not a good idea to use Node: Title as the argument. Instead, consider using "content/NID", where NID is the Node ID of the row's node, as the link in the original view Then, instead of the Node: Title argument in your view, use the Node: ID argument. This should make it less error-prone.

Related

Drupal Lightbox issue (not jQuery lightbox)

I am having a issue in Flag_list module, can anyone please help me out how to put a flag list and how to view it please?
The module has very good description how to do it : http://drupal.org/project/flag_lists
How to use:
Install as usual.
At admin/build/flags you will see a flag "fl_template." This is a default template flag provided by flag_lists. You can edit it to make changes to list messages and to assign it to node types. This
template will be used only on types you assign.
You can create new templates here: admin/build/flags/lists/template and apply them to other node types.
A template can be assiged to many node types, but a node type can only have one template assigned to it.
Enable the "list" block so that it is displayed on your content. The block will only be visible if the content is listable and the user has permission to create lists. That is, the node type must be assigned a template, or the block won't appear. Further, you should enable the link to create lists in the block's config.
Create new lists using the link in the block.
See your lists and listed content at user/[uid]/flags/lists

Drupal: How to theme view

i have row style set to NODE in my view.
I need to access "title" field of every node and modify it's, say, color and print it.
Then I need to print content.
How do I loop through the nodes and access fields inside each node? I just do not know how to count total number of nodes, and how to access each field in the node.
Thanks!
Instead of trying to loop through the nodes, you are almost certainly better off switching to a Row style of Fields and using (or overriding) the the per field templates that views provides.
That said, if all you really need to do is color a field, you can do that in CSS with the existing classes that Views adds by default.
You can edit directly the node-NODETYPE.tpl.php, adding your html before and after the title.
Your javascript function can then check whether the node is being printed within the appropriate view or not.

Drupal, Views: Search FIlter, how can I ignore some nodes?

I'm using "Search" exposed filter in Views (DRupal):
It works great, however I would like to ignore a specific node, if it is possible, and always display it, regardless the filter options.
how can I do that ? Is possible to specify the Search filter for only a specific content type ?
thanks
Here's what to do:
Add a new display to your view that is an attachment view. In the attachment, override all of your other filters etc and set up the view so that it just loads the single node that you want. Attach this view to the top or bottom of your search view as required.
In your search view, add an argument of node id and hard code a default argument that is the id of the node you display in the attachment. Exclude this argument from the view.
Finbarr's answer is pretty solid. The one thing its missing is the answer to whether you can exclude a specific content type from the search view... yes, you can.
On the display that is your search view, add a Node: Type filter and select "Is not one of" and the content type you want to exclude.

Drupal: can I specify a View for my search results?

I have a "Search" field in my website and I was wondering if I can assign my View to the search results, instead of using the default list.
Is this feasible ? How ?
thanks
It is possible to handle the search output by a view using the default search forms without exposing filters:
create a view of type content which displays all content types, display page
set Path: /search/node/%
add Contextual Filter "Search: Search Terms", then set "Provide default value" and "Raw value from URL" and "Path Component" to "3".
Now, every time you search for a node your view gets called instead of the default search result page because it is using the same path than the default search. The % is the argument which is handled by the Contextual Filter. Do not forget to set the filter to the 3rd component of the path which is the placeholder "%".
You can replace the default Search with a Views search instead. I haven't done this personally, but from what I've read it sounds straight forward. Create your "Search" View, then display it's "exposed filter" form instead of the default search form. More details here... http://groups.drupal.org/node/18582
Or, if you just want to make the search results look different, you can simply theme them, instead of using Views to do the searching. You can also control what fields (CCK and such) get displayed in the search results on the Display Fields > Search tab when editing the content type. I don't know the name of the template file for themeing search results of the top of my head, but if you have Theme Developer installed you can easily figure this out.
I've actually found the item "Search" in my Filters options in Views. I dunno how I could ignored it before. It actually exists, and works quite well. Solved.
You can use views to do search with exposed filters etc, but this is not a functionality that you can put on the search you have already. You can create a block in your search view and with theming replace what you got now with it instead.
This probably requires some work since the search box is usually not located in a region.

Drupal User Profile

One of my favourite sites at the moment is developmentseed.org. I really like what they do with there user profiles. How would you go about recreating it.
http://developmentseed.org/team seems to be a view of users/nodes
/team/eric-gundersen is a profile/node
"Posts by Eric Gundersen" block on the right of 2. seems to be a view. Is an argument being parsed to return content by Eric?
/blog/2009/oct/21/announcing-managing-news-pluggable-news-data-aggregator the user name links to the profile/node
Same link as above seems to be a block (teaser I guess).
Do you think there are using the defaults drupal module or a custom content type? How would you go about trying to implement something like this?
Thanks
Ryan
This seems to be a view of users with 3 fields: The avatar, the title of the user node (see 2) and the role name.
They're most likely using Content Profile.
In Views you can add an argument and specify that when no argument has been supplied (as is always the case for a block) a default value should be used. Among those default values you can select the user id from the current path. By adding a argument for the author of a node and specifying a default argument for it you can limit a node list to just the nodes created by that author.
I think this is built in functionality - the nice URL is probably an alias for user/123 created through PathAuto.
The block is probably a variant of 3 - the default argument is to take the id from the currently shown node instead and the teaser comes from the node linked to the user with the module described in 2.
So - to create something like that I would install Content Profile and then create some Views with arguments that has default values and with block displays. Does that help? :)
Of course, you can easily custom and theme the related User Profile page by including a user-profile.tpl.php file in your theme.

Resources