سؤال

I am building a Drupal site which will need a specific menu structure.

2 menu links, 'Recent Work' and 'Archives'

On clicking recent work, a list of 'Recent Articles' is shown with views as a menu in the page sidebar. However when clicking the linked title in that sidebar I want the path to be .com/recent-work/node-1 and the sidebar 'Recent Work' list remains.

On clicking Archive, a list of all nodes are displayed in the sidebar, upon clicking the linked title full node shows with the path .com/archives/node-1 and the sidebar 'archives' list remains.

The aim of this is to make the lists of work stay on screen when the user is looking trough that specific node type.

هل كانت مفيدة؟

المحلول

Assuming the view in the sidebar is a block placed in a sidebar region, I think you could do it like this:

  1. Use the Path module (in core) to create two URL aliases for each node. So aliases for node/1 would be:
    • recent-work/1
    • archives/1
  2. Use the Context module, to create two contexts, one for recent work, one for archives. These will affect the layout of the page based on what is in the URL path (using wildcards). For example:
    • Recent Work Context: if path = recent-work/* then show the "recent work" view in the sidebar.
    • Archives Context: if path = archives/* then show the "archives" view in the sidebar.
  3. Ensure the links in each view point to the corresponding aliases. This means if a link is in the recent-work view, the link should go to recent-work/1 (and likewise for the archives view). To do this:
    • Add a field to each view for "Content: Nid" but exclude it from display (it is needed as a token)
    • Edit the field you are displaying as a link, and go to Rewrite Results > Output this field as a Link. Then in the place you enter the link path, use a URL with the node id token. I think it would be something like: archives/[nid] (or recent-work/[nid], for the other view).

That ought to cover everything you are looking for. It would be really slick if when future content is created, you were able to automatically build the aliases from step 1. You may get some ideas from this post, if you are interested in that.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top