0

Forgive me if this is a repost, but I have spent days trying to figure this out and everything I have found on drupal.stackexchange and elsewhere have been no help and I am struggling to understand the what views is doing exactly... Here's my problem:

I have a website that has 2 different content types: category and static content.

Within category content type, three pieces of content: little, medium, and big.

In the static content content type, I have a autocomplete entity reference field called "Category" that points back to the category content type. Next, I have three more pieces of content:

article1, article 2, article3.

Each has a unique title, no path alias set and the category reference field set to "little."

(Just using the "little" category for this question)

So, my goal here is to have the user enter the URL

www.example.com/category/article-title

and have a view generate the output (I don't want direct access to the node as I want to control all the content formatting).

Now, I can do a "simple" filter on the Content: Category (field_category) for "little" and the view will display all articles where that condition in met. My problem comes in with the contextual filter and a URL alias.

No matter what I do in contextual filters, if I use a path alias, it will not work. However, if I use a node number (in this case, 2 for "little"), it will work properly. For instance:

www.example.com/little

will show no results. But,

www.example.com/2

works (2 is the node number for "little"). In this case, the view generates output with content from node 4 (an article with the title "Little Brown Jug"). This is what it is supposed to do.

I have used both page view and block view, I have created relationships linking the content referenced and the content referencing the category field. (I am sure this works as I can create related article pages with these relationships)

Whether I do this on the preview panel or directly on the URL, the results are the same. the term "little" generates no output, yet "2" does.

Any help here understanding this would be greatly appreciated.

I have added some screen shots

View Configuration page.  This one is set up as a block and I do have the block configured to display (it works when I select see all results)

Results when entering the nid of the content type *little*

Results when entering the alias of the content type *little*

contextual filters config page.  here I am pulling the 1st raw value from the URL

  • see my comment to your previous post replace [nid] with [node:menu-link:url:alias], will that solve the issue? – longboardnode Jun 10 '15 at 13:03
  • That suggestion worked for formatting the results so I could click on a result and ensure that it goes through the views page. The problem I am having here is just displaying content based on URL alias as opposed to nid. I am manually typing in the URL alias and it dosen't work. However, using the node ID does. – Allan Jun 10 '15 at 13:08
  • What fields are you selecting for the contextual filters? Try filtering against Content:Title... – longboardnode Jun 10 '15 at 13:13
  • Tried that too..it just won't take text. It seems to only like node numbers. I must be missing something, I just don't know what. – Allan Jun 10 '15 at 13:16
  • I see. Can you attach a screengrab of the view with the context filters dialog box open so we can see your settings? – longboardnode Jun 10 '15 at 13:24
1

If you set the Views page path to node/% and add a Contextual Filter of Node ID and take the default argument from the URL you can use Views to override the node display.

However, this is probably not the best solution. You mention in your post that "I don't want direct access to the node as I want to control all the content formatting" but if you use the correct options you can fully control the node output. My recommendation would be to use Display Suite and control everything via the Manage Display tab of the content type and if necessary an override of node.tpl.php

  • I may end up doing that but I really don't want to add another module just to solve a problem that is supposed to already be solved by Views. Besides, I want to fully exhaust my options here as to fully learn this module – Allan Jun 10 '15 at 13:23

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.