3

I'm creating a feed view that generates a specially-formatted file when nodes of a specific content type have /tsv appended to the path (generated by path_auto)

I.e.,

How do I do this? I have node/%/tsv as the feed path, Node: Nid as argument (with "Node ID from URL" as the "Action to take if argument not present").

I feel there must be something really obvious I'm missing... Apologies if this has been covered before, I really did look for a solution before posting.

Thanks!

2

The Sub-path URL Aliases module should do what you're looking for (I use it successfully with Views arguments)...

From the module page:

For example, if node/1 is aliased to content/alias, this module rewrites the link to the node edit page node/1/edit to use the aliased URL content/alias/edit instead. This also includes Views URLs taking a node as argument (node/%/yourview), in short, every URL that is based on, or extends, an existing alias.

  • I can vouch for the Sub-path URL Alias module, very handy for making Pathauto and Views work together seamlessly. – Jim Kirkpatrick Dec 24 '11 at 1:31
2

I'm not sure if I understood you question but I think the answer is:

In Arguments set Node: Nid as argument. Then set Provide Default argument and choose NODE ID from URL.

Here are all the steps.

You have 2 different views to your node.

  1. Normal view. URL-> mydomain.com/node/%nid/ shows your node content
  2. Feed view. URL -> mydomain.com/node/%nid/tsv shows your feed.

But when you navigate to mydomain.com/node/%nid/tsv it does not work right? So what you're asking is how you "create" this URL in order to show the feed... is that it?

If that's the case, in VIEWS2:

  1. Create a new PAGE display.
  2. In Page settings (bottom left corner) there's an option called PATH. Set this to node/%/tsv.
  3. Still in Page Settings theres an option called menu. Set this to Menu Tab if you wish to show a tab linking to your view. | view | TSV |
  4. In Arguments set Node: Nid as argument. Then set Provide Default argument and choose NODE ID from URL.
  5. Validation set Basic Validation (or Node Type if the Feed is only available to certain node types)
  6. In fields, select the fields you wish to show.
  7. Add a filter to node published (to show only if the node is published) and a filter user role (to limit access to certain users)

And that's it... when you navigate to mydomain.com/node/%nid/tsv it shows the fields you selected.

  • Apologies for taking so long to get back to you. This solution doesn't really work for me, I'm using pathauto and my content is listed i.e. domain.com/content/the-title-of-the-sheet. How would I do this with /content/ as the slug? – aendrew Jul 4 '11 at 2:32
  • That said, the tip on adding a new tab was a really good idea. +10! – aendrew Jul 4 '11 at 3:05
  • 2
    it's the same thing actually. Path auto adds an alias to a determined path but the "original" path still exists. Now, if you want a content/the-title-of.post/tsv then you should use subpath module like franky said. – Tivie Aug 28 '11 at 16:47
0

Building on Tivie's answer and updating for views3, without using the subpath module...

I suggest using the path node/%/%/tsv instead of node/%/tsv. To do this, start by changing the replacement pattern in PathAuto for your content type to

node/[node:nid]/[node:title] 

Remember to delete all aliases then do a bulk update for your content.

Note, you can use whatever path you like instead of "node" in the first position in the path. e.g. questions/[node:nid]/[node:title], cats/[node:nid]/[node:title], fish/[node:nid]/[node:title].

Your view path is now node/%/%/tsv instead of node/%/tsv. This allows Contextual Filter in Views (arguments for Views2) to work off the nid but retains the SEO friendly node title. i.e. exactly as stackexchange does in this question.

The next part creates a View that shows a single node for a content type when you visit the path node/%/%/tsv.

  1. Structure > Views > Add new Views
  2. Add a view name
  3. Show Content of type your-content-type
  4. In Path, set this to node/%/%/tsv. (note, "node" could be "questions", "fish", "cats", nothing, or whatever
  5. Press Continue and Edit
  6. On the next page, set up the format and fields as you want them to be displayed when the user visits the page. I use display suite view modes to provide different ways of presenting the content type - useful if I clone views and have several paths. e.g. node/%/%/tsv, node/%/%/images/, node/%/%/friends.
  7. In Advanced, Contextual Filter, select Add, and add Node: Nid from the list.
  8. In the field group "When the filter value is NOT in the URL", select Provide Default Value > Content ID from URL
  9. In the field group "When the filter value IS in the URL or a default is provided" select Specify Validation Criteria > Content and choose the Content Type for the node
  10. The Filter Value format shoud be Node ID and the action to take Show "Page Not Found"

When you navigate to mydomain.com/node/%/tsv it shows the fields you selected in the arrangement you chose with display suite modes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.