0

I am writing a view that lists all content of a specific type. I would like to, additionally, be able to set paths to content made by a specific user. For example drupal.dd/content will give all content. Then drupal.dd/%/content will show only the content by a specific user where % is the user's name. The issue I have come across is, when I create the path with /%/content it says the first segment of the path cannot be %. I am using a contextual filter to filter by author. How would I go about doing so. I am using Drupal 8.

0

You should already have a path for this at drupal.dd/content/[author] based on how you have setup the contextual filter. If you are using a contextual filter, they will get appended to the path of the view, and it sounds like your view has a path of "/content".

  • Is there a way to do /%/content ? Without withing the contextual filter perhaps? – Kevin Jul 14 '17 at 20:14
  • I assume you are asking about still utilizing views. As you mentioned, you cannot have a wildcard as the first part of the path. So you could put something else there to have it be /[something]/%/content. Is there a reason that you are opposed to just using "/content" as everything and "/content/[author]" as the filter by author? – Brian Williams Jul 14 '17 at 20:21
  • I am recreating an existing site in Drupal 8 that is currently using Drupal 6. The current format must be maintained :/. Is there a way to do this which would not be using views? – Kevin Jul 14 '17 at 20:26
  • How was it done on the 6 site? did they do a custom module with a hook_menu and define a page callback for the "%/content" paths? You can do a similar thing in 8 using routes with wildcards as well. – Brian Williams Jul 14 '17 at 20:32
  • Just follow the conventions. A route should not start with a contextual filter. – Kevin Jul 14 '17 at 21:51

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.