1

My question is rather simple, but I didn't manage to find anything that can help.

Summary of my setup :

So I have various custom content types, which I want to organize using views. But for SEO reasons, I want them to use simplified URLs, generated by Pathauto.

These content types are all cross-referenced using Entity Reference, and when I try to configure my View "Page" using the node ID as contextual filter, it works. But when I try to use Pathauto, nothing happens.

So how can I use Views, basically when going to http://example.com/fruits/banana and pass "banana" argument to Views, to filter my content ?

I am searching for it for almost a week, and I am lost.

2 Answers 2

0

I couldn't understand what you exactly need but i guess that "banana" is the title of your node, the same value that you are using when you set up the pattern in pathauto settings, right?

So in this case you would have to set Node Title has a contextual filter, and then on "When the filter value is NOT available" you have to set Provide default value > Raw value from URL > specify the position of your argument in the URL.

It would be nice if you give us more information about what do you need, please

8
  • The fact is that when I use in the View example.org/node/123 for instance, or even example.org/fruits/123, my view works, but not when I use the alias, the behaviour is the same as "not found"
    – Marcandria
    Commented May 19, 2015 at 0:32
  • "banana" is the title of node 123? Could you share a screenshot of your settings?
    – xstean
    Commented May 19, 2015 at 14:15
  • I configure my Drupal in English and I get back to you with caps.
    – Marcandria
    Commented May 19, 2015 at 18:35
  • So here's the setup : i.imgur.com/U2j4QGt.png My request using node ID works : i.imgur.com/ItMn19e.png But not my request using pathauto alias : i.imgur.com/SVOom3v.png
    – Marcandria
    Commented May 19, 2015 at 18:41
  • Sorry, still needing more info. I think the problem is in the configuration of your contextual filter (could you share a screeshot of that section). Did you tried setting the structure that i told you at the beginning of that answer?
    – xstean
    Commented May 19, 2015 at 18:59
0

After extended search and help from user xstean, I went with the idea of overriding node/% of Drupal with a custom View, for my specific content type. This way, I would have more control on what is shown or not.

I managed to get myself out with help from this post : What are the issues with overriding nodes with views?

So basically what I did was :

  • Created my View, without any display mode, only "Master". I checked with the preview function and a node ID, it works. It doesn't works with pathauto alias, but it's not a problem yet.
  • Went to my templates folder, and edited node.tpl.php to copy the one proposed at the end of the post and embedded my view directly in it :

    <?php if ($node->type=='FANCYTYPE'): ?>
        <?php print views_embed_view('name_of_fancy_view', 'default', $node->nid); ?>
    <?php else: ?>
        // the rest of the normal node.tpl.php stuff here
    <?php endif; ?>
    

In fact, I understood you can't override the node/% view for one content type without causing trouble for the others, so this snippet helped a lot.

So i'll go that way, it's a bit "clumsy" but works like a charm.

Somehow, if someone has a better technique to override node view for a specific content type, I'll be OK to try :)

Thanks xstean for great help !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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