0

Building a site with content types Business, Product, and Review. Currently when users click a business name, they are taken to the Full Content view for that Business (e.g. sitename.com/business/[business name] since we are using PathAuto).

Created a custom View called Profile (sitename.com/profile) with a contextual filter that shows a selected Business as a rendered entity followed by two view attachments that show their Products and Customer Reviews.

We can manually type sitename.com/profile/6 into a browser and see a business with the attachments for products and reviews, but we are having trouble getting users there.

Tried adding a new field to Business with a default value and tokens to generate a URL to the business' profile view (e.g. Link with a default value of "/profile/[node:id]"). This field would be hidden on the input form for Business but displayed on the Full Content view.

We have not been able to get this working and do not know a better way to approach the challenge. If it is possible to get the Products and Reviews to display on the Business content page without using the Profile view (e.g. User clicks a Business name and sees their profile with products and reviews underneath), that would also meet the requirement.

Would prefer to do this without custom coding if possible, but acceptable if it is the only or best way. Happy to answer questions for clarification or provide links to the site (still in beta) if it would help.

1

Going from node/6 page to profile/6 page (which displays products and reviews) there is a simple module that can help with this https://www.drupal.org/project/field_token_value

It will allow you to add a field PROFILE PAGE hidden from the editor and can be configured to have the value of

<a href='/profile/[node:nid]'>profile page</a> 

after that go to the content type display admin/structure/types/manage/CONTENTTYPE/display to configure where should be displayed

The field will not be available on the edit form and after saving it will hold a link to profile/[nid]

Above module works in both drupal 7 and 8

More involved alternatives

you could use https://www.drupal.org/project/linked_field and https://www.drupal.org/project/field_permissions (drupal 7 & 8)

For drupal 7 projects https://www.drupal.org/project/token_field does the same thing

  • This worked very well. Seemed not to at first, until I discovered the setting to enable token translation in the various text formats (admin/config/content/formats). After turning on "Replaces global and entity tokens with their values," it worked like a charm, thank you! – Brian Slickis Mar 12 '17 at 21:00
0

This sounds like another job for my friend EVA (Entity Views Attachment). Rather than having two Views attachments, you could rework those two displays to become entity views attachments and have them show up on your sitename.com/business/[business name] page.

From the module description:

"Eva" is short for "Entity Views Attachment;" it provides a Views display plugin that allows the output of a View to be attached to the content of any Drupal entity. The body of a node or comment, the profile of a user account, or the listing page for a Taxonomy term are all examples of entity content.

The placement of the view in the entity's content can be reordered on the "Field Display" administration page for that entity, like other fields added using the Field UI module.

  • I was given new instruction by the boss (wife :) to stick with a "View My Products" link from the business pages, but this EVA module looks fantastic, and I can already see a couple of other ways we might use it on this site and another we are working on. Thank you very much for the suggestion! – Brian Slickis Mar 12 '17 at 21:02
  • Good luck with it :) – Neograph734 Mar 12 '17 at 21:10

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.